lxnski
October 12th, 2010, 10:48 AM
Dear Ubuntu Forums,
I am new to Python (and Linux) and have been studying from the book "Beginning Python - Using Python 2.6 and Python 3.1)
One of the codes which I have written is the following:
age=0
while True:
how_old=input("Enter your age: ")
if how_old=="No":
print ("Dont be ashamed of your age!")
break
num=int(how_old)
age=age+num
print ("Your age is: ")
print (age)
print ("That is old!")
When I write and save this as .py through GEDIT everything runs perfectly. However, when I write this in the Ubuntu Python terminal and press enter, the program does not run completely. It prompts me for my age, and when I type "No" it gives me the following error:
Traceback (most recent call last):
File "<stdin>", line 2, in <module>
File "<string>", line 1, in <module>
NameError: name 'No' is not defined
Why am I getting this error when I run through the Terminal and not when I save as .py through GEDIT and open with the Python GUI??
Thanks in advance.
I am new to Python (and Linux) and have been studying from the book "Beginning Python - Using Python 2.6 and Python 3.1)
One of the codes which I have written is the following:
age=0
while True:
how_old=input("Enter your age: ")
if how_old=="No":
print ("Dont be ashamed of your age!")
break
num=int(how_old)
age=age+num
print ("Your age is: ")
print (age)
print ("That is old!")
When I write and save this as .py through GEDIT everything runs perfectly. However, when I write this in the Ubuntu Python terminal and press enter, the program does not run completely. It prompts me for my age, and when I type "No" it gives me the following error:
Traceback (most recent call last):
File "<stdin>", line 2, in <module>
File "<string>", line 1, in <module>
NameError: name 'No' is not defined
Why am I getting this error when I run through the Terminal and not when I save as .py through GEDIT and open with the Python GUI??
Thanks in advance.