View Full Version : Really n00bish python question
Gnobody
April 23rd, 2005, 09:12 PM
I was reading some Dive into Python for the first time and I was wondering why my simple name/string program doesn't work:
print "Welcome"
print
name = raw_input("Please enter in your name: ")
if name == "Jason" then
print "Hello Jason!"
else
print "Go away!"
sas
April 23rd, 2005, 09:45 PM
I was reading some Dive into Python for the first time and I was wondering why my simple name/string program doesn't work:
Your problem is missing ":" after if and else, also next isn't a keyword in python (iirc)
your code should look more like this:print "Welcome"
print
name = raw_input("Please enter in your name: ")
if name == "Jason":
print "Hello Jason!"
else:
print "Go away!"
Gnobody
April 24th, 2005, 12:46 PM
Your problem is missing ":" after if and else, also next isn't a keyword in python (iirc)
your code should look more like this:print "Welcome"
print
name = raw_input("Please enter in your name: ")
if name == "Jason":
print "Hello Jason!"
else:
print "Go away!"
Wow, Python and Gedit pwn me. Now to learn PyGTK...
vBulletin® v3.8.7, Copyright ©2000-2012, vBulletin Solutions, Inc.