Oct-01-2017, 01:36 AM
I am trying to write a rock, paper, scissors function without using if statements, loops or lists
The function prompts the user for choice of player 1 and then choice of player 2, and then it displays;
1."Player 1 wins. That is True. It is a tie. That is not True." If player 1 wins
2."Player 1 wins. That is False. It is a tie. That is not True" If player 2 wins
3.'Player 1 wins. That is False. It is a tie. That is not False' If it is a draw
I am having trouble figuring out a way such that the function prints only the correct statement depending on the inputs
This is how far I got:
The function prompts the user for choice of player 1 and then choice of player 2, and then it displays;
1."Player 1 wins. That is True. It is a tie. That is not True." If player 1 wins
2."Player 1 wins. That is False. It is a tie. That is not True" If player 2 wins
3.'Player 1 wins. That is False. It is a tie. That is not False' If it is a draw
I am having trouble figuring out a way such that the function prints only the correct statement depending on the inputs
This is how far I got:
def rps_winner(): p1= input('What choice did player 1 make ?' +'\n'+'Type one of the following options: rock, paper, scissors: ') p2= input ('What choice did player 2 make?'+ '\n'+'Type one of the following options: rock, paper, scissors: ') p1wins= (p1=='rock' and p2== 'scissors') or (p1=='paper' and p2=='rock') print ('Player 1 wins. That is True'+'\n'+'It is a tie. That is not True') p2wins= (p1=='rock' and p2== 'paper') or (p1=='paper' and p2=='scissors') print ('Player 1 wins. That is False'+ '\n'+'It is a tie. That is not True') tie= (p1=='rock' and p2== 'rock') or (p1=='paper' and p2=='paper')or(p1=='scissors'and p2== 'scissors') print ('Player 1 wins. That is False'+'\n'+'It is a tie. That is not False')