blackcoffeeblue
March 4th, 2009, 02:47 PM
Hi all,
Just starting out with python :) I have a syntax error on line 9 - can anyone tell me what I'm doing wrong? I thought a colon was necessary here to indicate a block of statements to follow?
#!/usr/local/bin/py3k
#filename: while.py
age = 15
asking = True
while asking:
guess = int(input('Guess my age: ')
if age > guess:
print('I\'m older')
elif age < guess:
print('I\'m younger')
else:
print('That\'s right I\'m', age)
asking = False
else:
print('Loop over')
print('Program over')
File "while.py", line 9
if age > guess:
^
SyntaxError: invalid syntax
Just starting out with python :) I have a syntax error on line 9 - can anyone tell me what I'm doing wrong? I thought a colon was necessary here to indicate a block of statements to follow?
#!/usr/local/bin/py3k
#filename: while.py
age = 15
asking = True
while asking:
guess = int(input('Guess my age: ')
if age > guess:
print('I\'m older')
elif age < guess:
print('I\'m younger')
else:
print('That\'s right I\'m', age)
asking = False
else:
print('Loop over')
print('Program over')
File "while.py", line 9
if age > guess:
^
SyntaxError: invalid syntax