[Tutor] Output never stops

David david at abbottdavid.com
Sun Aug 3 04:21:33 CEST 2008


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 choice == 'Lary':
>       print "Lary's age is:", person.get('Lary')
>
>   elif choice == 'Joan':
>       print "Joan's age is:", person.get('Joan')
>
>   else:
>        print 'Bad Code'
>
should have been like this;

#!/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':
       print "Lary's age is:", person.get('Lary')

   elif choice == 'Joan':
       print "Joan's age is:", person.get('Joan')

   else:
        print 'Bad Code'


-- 
Powered by Gentoo GNU/LINUX
http://www.linuxcrazy.com



More information about the Tutor mailing list