python - How to check a variable against 2 different strings? 9 line example -


why doesn't work?

rank=input("is realm duchy, kingdom or empire? ")   if rank=="duchy"or"duchy":       realm=input("what duchy named? ")   elif rank=="kingdom"or"kingdom":       realm=input("what kingdom named? ")   elif rank=="empire"or"empire":       realm=input("what empire named? ")   else:       print("restart , duchy, kingdom or empire. ")   

no matter answer, asked duchy named.

it's evaluating if "dutchy", returns true

you need

if rank=="duchy"or rank == "duchy": 

or better yet,

if rank.lower() == "duchy": 

Comments

Popular posts from this blog

python - jinja2: TemplateSyntaxError: expected token ',', got 'string' -

node.js - NodeJS remote terminal to Dropbear OpenWRT-Server -

Qt4: how to send QString inside a struct via QSharedMemory -