On 12/11/2016 11:30 AM, oliver patterson wrote:
hey i dont know if this is the right place but i was just coding in idle and
kept getting this syntax error and i can not see m to fix it here is my bit of
code:
my_age=14
age=input("How old are you?:")
print("type start()")
def start():
print("hey")
if age == my_age:
print("i'm",age,"too")
else:
if age < 14:
print(" i'm older that you i'm",my_age,":)")
else:
print("your older than me i'm",my_age,":(")
please help thank you.
IDLE's way of reporting some errors is different than the standard
traceback, so you may not be able to follow Bob Stepp's advice.
When I select Run on your module I see the first "else" highlighted in
red, and the invalid syntax message.
If you undent the else blocks giving:
my_age=14
age=input("How old are you?:")
print("type start()")
def start():
print("hey")
if age == my_age:
print("i'm",age,"too")
else:
if age < 14:
print(" i'm older that you i'm",my_age,":)")
else:
print("your older than me i'm",my_age,":(")
the program will pass the syntax checks. When you run it it will fail:
How old are you?:as
type start()
>>> start()
hey
Traceback (most recent call last):
File "<pyshell#0>", line 1, in <module>
start()
File "C:/Python35/oliver.py", line 9, in start
if age < 14:
TypeError: unorderable types: str() < int()
>>>
Can you figure out why? Can you propose a fix?
If you want to impress potential employers I recommend cleaning up your
English.
_______________________________________________
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor