python - How can I match input in a case insensitive manner? -


i making mud, or sud can call (singleplayer) way navigate through game type commands.

def level_01_room_01():     choice = raw_input('>: ')     if choice == 'north':         level_01_room_02() 

in case, if user enters north, capital n, code not perceive command. big mess if have enter:

def level_01_room_01():     choice = raw_input('>: ')     if choice == 'north':         level_01_room_02()     if choice == 'north':         level_01_room_02()     if choice == 'north':         level_01_room_02() 

etc.

is there way can fix this, player can type word or wants to?

always lower() user input before comparing against known strings (and use lower case).

if choice.lower() =='north':     ... 

Comments

Popular posts from this blog

plot - Remove Objects from Legend When You Have Also Used Fit, Matlab -

java - Why does my date parsing return a weird date? -

Need help in packaging app using TideSDK on Windows -