LuukV
LuukV

Reputation: 203

my idea - is this proper coding?

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

Answers (1)

dawg
dawg

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

Related Questions