Here are the rules. You and your opponent, at the same time make a specific gesture, must be the following gesture: stone, scissors, cloth. Victor from
In the following rules, the rule itself is a paradox.
(a) cloth-clad stones.
(b) The stone hit the scissors,
(c) Scissors cut the cloth. In your computer version, the user enters her/his options, the computer is looking for a random option, and then by you
Program to determine a winner or a tie. Note: The best algorithm is to use the IF statement as little as possible
Copy the Code code as follows:
#coding: Utf-8
Import Random
Guess_list = ["Stone", "scissors", "cloth"]
Guize = [["Cloth", "stone"],["stone", "Scissors"],["scissors", "cloth"]
While True:
Computer = Random.choice (guess_list)
People = input (' Please input: stone, scissors, cloth \ n '). Strip ()
If people not in Guess_list:
People = input (' re-enter: stone, scissors, cloth \ n '). Strip ()
Continue
if computer = = People:
Print ("Tie, play again!") ")
elif [Computer,people] in guize:
Print ("Computer wins!" ")
Else
Print ("Man wins!" ")
Break