Python Programming Exercises, Gently Explained
69
this exercise is a set of if-elif-else statements. The player1 parameter contains a string of the
first player’s move and the player2 parameter contains a string of the second player’s move. These
strings will be one of 'rock', 'paper', and 'scissors'. You’ll want to use comparison
operators to check the value of both players and join them with an and operator. For example, the
expression player1 == 'rock' evaluates to True if the first player went with rock, and the
expression player2 == 'paper' evaluates to True if the second player went with paper. This
means that in the expression player1 == 'rock' and player2 == 'paper' evaluates to
True
if both sides of the and operator evaluated to True. In this case, the second player is the
winner and the function should return 'player2'.
Dostları ilə paylaş: