I've started learning Python recently and as a practise I'm working on a text-based adventure game. Right now the code is really ineffective as it checks the user responce to see if it is the same as several variations on the same word. How do I change it so the string check is case insensitive?
Example code below:
if str('power' and 'POWER' and 'Power') in str(choice):
print('That can certainly be found here.')
time.sleep(2)
print('If you know where to look... \n')
'power' and 'POWER'
doesn't do what you think it does, it merely evaluates to'POWER'
, and that callingstr(...)
on the strings is probably redundant and possibly breaks your program (e.g. it could break it for some custom string or string-like classes).