mardi 27 janvier 2015

What is the cause of the syntax error in greater than or equal "if statement"?

The following code I wrote was part of an in-class exercise on making "if-statements" in python, which I saved as x.py.



name = raw_input()("Please enter your name:")
print ("Hello", name)
age = int(raw-input("what is your age?"))
print "according to you, your age is", age
print "in a year you will be ", age +1
#if age is >= 21 print "In the state of Massachusetts, you can legally purchase alcoholic drinks"
if age is => 21:
print "In the state of Massachusetts, you can legally purchase alcoholic drinks."
else:
print " something else…"
print "here’s one more thing…"


The problem is that when I try to run the program in Terminal, I get the following error:



File "x.py", line 7
if age is => 21:
^
SyntaxError: invalid syntax


I've tried reentering the line, looking up examples of conditional statements, and scouring stackoverflow for similar questions, but couldn't find any that had an error that was very close to mine. I also can't reach my professor or my TA because of the snowstorm in New England. I'm using Python 2.7.9 on a mac book in v10.9.5. I would greatly appreciate any assistance.


Aucun commentaire:

Enregistrer un commentaire