Python Forum
rock,paper,scissors - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: Homework (https://python-forum.io/forum-9.html)
+--- Thread: rock,paper,scissors (/thread-1102.html)

Pages: 1 2


RE: rock,paper,scissors - Jei - Dec-06-2016

well in my lesson the AI only does 1 input thats wrong: Spaceshuttle
that i handled with this code:


elif player == ("Spaceshuttle"):

           print("Incorrect selection.")
i couldnt figure out how to do it for all wrong inputs xD


RE: rock,paper,scissors - nilamo - Dec-06-2016

Use an 'else' clause:

player = "some-response"
if "rock" == player:
    # do things
elif "paper" == player:
    # do things
elif "scissors" == player:
    # do things
else:
    print("not a valid response")