Python 2.7 accepting capital letters -


so i've got program , encrypts text in many different ways (for exam practise) , don't know how make menu function accept capital letters aswell lower case letters

def getmenuchoice():   menuchoice = raw_input()   print   return menuchoice 

use either str.lower() or str.upper() convert text lowercase or uppercase:

def getmenuchoice():   menuchoice = raw_input("enter choice: ")   return menuchoice.lower()  expected="menu1" while getmenuchoice() != expected.lower():     print "try again" print "correct input"     

demo:

enter choice: menu try again enter choice: mennu try again enter choice: menu1 correct input 

Comments

Popular posts from this blog

php - Why I am getting the Error "Commands out of sync; you can't run this command now" -

linux - Does gcc have any options to add version info in ELF binary file? -

java - Are there any classes that implement javax.persistence.Parameter<T>? -