David wrote:
[snip]
#!/usr/bin/python
person = {'Lary':43,'Joan':24}
choice = 0
while choice != '-1':
if choice == '':
print "You must enter Lary or Joan to continue! (-1 to quit): "
choice = raw_input(
"Who's age do want to know, Lary or Joan? (-1 to quit): ")
if ch
"David" <[EMAIL PROTECTED]> wrote
Thanks Alan, also your tutorial/book is a big help. I think I got it
:)
Close but not quite there yet.
choice = 0
while choice != '-1':
if choice == '':
print "You must enter Lary or Joan to continue! (-1 to quit):
"
choice = raw_input(
Alan Gauld wrote:
"David" <[EMAIL PROTECTED]> wrote
the output never stops when I run this in a terminal
choice = raw_input("Enter the name Lary or Joan (-1 to quit): ")
while choice != '-1': person = {'Lary': 43,'Joan': 24}
if choice == 'Lary':
print "Lary's age is:", perso
"David" <[EMAIL PROTECTED]> wrote
the output never stops when I run this in a terminal
choice = raw_input("Enter the name Lary or Joan (-1 to quit): ")
while choice != '-1':
person = {'Lary': 43,'Joan': 24}
if choice == 'Lary':
print "Lary's age is:", person.get('Lary')
Hi David,
Simple explanation - you should use if instead of while. A while
statement executes whatever is in that block again and again until
the condition becomes false. So your code, the way you have it, first
checks if the user's input is not -1. If you have typed Lary, it goes
on to p
David wrote:
Very new to python and never programed before. Can not figure out why
the output never stops when I run this in a terminal
#!/usr/bin/python
choice = raw_input("Enter the name Lary or Joan (-1 to quit): ")
while choice != '-1': person = {'Lary': 43,'Joan': 24}
if choi
Very new to python and never programed before. Can not figure out why
the output never stops when I run this in a terminal
#!/usr/bin/python
choice = raw_input("Enter the name Lary or Joan (-1 to quit): ")
while choice != '-1': person = {'Lary': 43,'Joan': 24}
if choice == 'Lary':