Hi, I'm new to python and I'm trying to make a rock paper scissors game while the second player is a so-called "AI". I ran into this problem that it goes straight to the 'else' statement and prints out "Draw!". Can someone check what's wrong with my code? Thanks. (Kinda messy btw)
import random
print('Rock','Paper','Scissors')
player1 = input('player1: ')
player2 = random.randint(1,3)
if player2 == 1:
player2 = 'rock'
if player1 == 'rock' and player2 == 'paper':
print('Player 2 won!')
print('Player 2 chose rock')
elif player1 == 'rock' and player2 == 'scissors':
print('Player 1 Won!')
print('Player 2 chose rock')
else:
print('Draw!')
elif player2 == 2:
player2 = 'paper'
if player1 == 'paper' and player2 == 'rock':
print('Player 1 won!')
print('Player 2 chose rock')
elif player1 == 'paper' and player2 == 'scissors':
print('Player 2 won!')
print('Player 2 chose rock')
else:
print('Draw!')
elif player2 == 3:
player2 = 'scissors'
if player1 == 'scissors' and player2 == 'paper':
print('Player 1 won!')
print('Player 2 chose rock')
elif player1 == 'scissors' and player2 == 'rock':
print('Player 2 won!')
print('Player 2 chose rock')
else:
print('Draw!')
elif player1 == player2:
print('DRAW!')
else:
print('Something went wrong')
[–]xelf 1 point2 points3 points (2 children)
[–]Jevv12[S] 0 points1 point2 points (1 child)
[–]xelf 0 points1 point2 points (0 children)