Python Forum

Full Version: My code won't say Player wins or computer wins. No errors.
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
#!/bin/python3

from random import randint

player = input('Paper(p), Scissors(s), or Rock(r).')

print(player, 'vs', end= ' ')
chosen = randint(1,3)
#print(chosen)

if chosen == 1:
  computer = 'r'
  
elif chosen == 2:
  computer = 'p'

else:
  computer = 's'

print(computer)

if player ==chosen:
  print('DRAW!!!!')

elif player == 'R' and computer == 'S':
  print("Player wins!!")

elif player == 'R' and computer == 'P':
  print('Computer wins!!')
  
elif player == 'P' and computer == 'R':
  print("Player wins!!")
  
elif player == 'P' and computer == 'S':
  print('Computer wins!!')
  
elif player == 'S' and computer == 'P':
  print("Player wins!!")
  
elif player == 'S' and computer == 'R':
  print('Computer wins!!')
The computer chooses lower case letters, the input could be either lower of uppercase.
The comparisons done are uppercase.

Note:
The string method upper or lower could be used to change the case.
random choice could be used to choose a string directly.
Thank You!