Reputation: 203
I came up with this idea, which I thought was pretty clever:
userinput = ''
while userinput != 'yes':
userinput= input('Pick first player randomly? (yes/no) ')
if userinput== 'no':
break
Is that proper 'pythoneese'? And is there a better or 'proper' way of doing this?
Upvotes: 0
Views: 40
Reputation: 104072
I would rewrite this way:
while True:
userinput=input('Pick first player randomly? (yes/no) ').strip().lower()
if userinput in ('no', 'yes'):
handle_user_input(userinput)
break
Upvotes: 2