On 11/3/2010 9:19 PM, braden faulkner wrote:
I'm using a menu for my command line app using this method.

choice = "foobar"
while choice != "q":
     if choice == "c":
         temp = input("Celsius temperature:")
         print "Fahrenheit:",celsius_to_fahrenheit(temp)
     elif choice == "f":
         temp = input("Fahrenheit temperature:")
         print "Celsius:",fahrenheit_to_celsius(temp)
     elif choice != "q":
         print_options()
     choice = raw_input("option:")

Just wondering if there is another or more efficient way I should be doing it?

Others have answered that, but I would point to the inefficiency for users of having to enter unit and value on two separate lines. The prompt could be "Enter value and unit (f, c, or k) or q to quit: "
Allow upper and lower case, with or without a space between.

--
Terry Jan Reedy

--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to