[Tutor] How to make to exit the loop, while typing Enter

Alan Gauld alan.gauld at freenet.co.uk
Tue Jan 3 22:45:54 CET 2006


> entries for the list , But if I press Enter it  should
> exit  the while loop without giving errors ,I have
> problem in making it work , right now if I press enter
> to exit , the program terminates showing error 

Thats because you can't convert an empty string to an int.

If you defer the conversion until you add the mark to the 
list then it should work OK.


> m = int(raw_input("Enter the  Values for  The Array : 
> "))
> array.append(m)

array.append(int(m))

HTH,

Alan G
Author of the learn to program web tutor
http://www.freenetpages.co.uk/hp/alan.gauld




More information about the Tutor mailing list