When you take input its bydefault is in string format you might want to typecast and validate teh input
On Tue, May 3, 2011 at 4:00 PM, Johnson Tran <aznj...@me.com> wrote: > Hi All, > > i am trying to create a program module with two functions (conversion > inches to centimeters then centimeter to inches, I have my program working > although I am trying to adda Value Error function to my program but cannot > seem to it to work: > > > def Conversion(): > print "This program converts the first value from inches to centimeters > and second value centimeters to inches." > print "(1 inch = 2.54 centimeters)" > inches = input("Enter length in inches: ") > centimeters = 2.54 * inches > print "That is", centimeters, "centimeters." > > centimeters = input("Enter length in centimeters: ") > inch = centimeters / 2.54 > print "That is", inch, "inches." > > except ValueError: > print "Invalid digit, please try again." > > Conversion() > > > > Any advice would be great, thanks! > > JT > _______________________________________________ > Tutor maillist - Tutor@python.org > To unsubscribe or change subscription options: > http://mail.python.org/mailman/listinfo/tutor > -- Nitin Pawar
_______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor