# Menu # using while loop # http://teampython.wordpress.com/2012/02/26/how-to-do-a-very-simple-menu/ ans= True while ans == True: ## Show menu ## print 30 * '-' print " M A I N - M E N U" print 30 * '-' print "1 Get a compliment" print "2 Get some advice" print "3 Get some information" print 30 * '-' ans = raw_input ('What would you like to do now ? ') if ans =='1': print('\nYou are looking great today') elif ans =='2': print('\nEat your greens! ') elif ans =='3': print('\nI am a python program called menu. ') elif ans =='': print('\nQuitting...') else: print('\nNot a valid choice!')
Run
Reset
Share
Import
Link
Embed
Language▼
English
中文
Python Fiddle
Python Cloud IDE
Follow @python_fiddle
Browser Version Not Supported
Due to Python Fiddle's reliance on advanced JavaScript techniques, older browsers might have problems running it correctly. Please download the latest version of your favourite browser.
Chrome 10+
Firefox 4+
Safari 5+
IE 10+
Let me try anyway!
url:
Go
Python Snippet
Stackoverflow Question