Reputation: 1
I am very much a beginner trying to build a beginner rock paper scissors game. I am having trouble comparing results between the player and the com (random), my if statement is not recognizing the com's move.
rock = '''
_______
---' ____)
(_____)
(_____)
(____)
---.__(___)
'''
``paper = '''
_______
---' ____)____
______)
_______)
_______)
---.__________)
'''
scissors = '''
_______
---' ____)____
______)
__________)
(____)
---.__(___)
'''
player = input('What do you choose? Type 0 for Rock, 1 for Paper or 2 for Scissors.\n')
if player == '0':
print(rock)
elif player == '1':
print(paper)
elif player == '2':
print(scissors)
print('Computer chose:')
handsigns = [rock, paper, scissors]
import random
random.shuffle(handsigns)
com = print(handsigns[0])
``if com == 'rock':
if player == '0':
print("Draw")
if player == '1':
print('You win')
if player == '2':
print('You lose')
Upvotes: 0
Views: 148
Reputation: 544
In your code you are assigning the return value of the print command to com
com = print(handsigns[0])
print in this case returns 'None', so that's what com will get assigned.
Try to print the value of com as a debugging step to see the value.
Additionally, handsigns is a list of the 3 display variables you defined above.
handsigns = [rock, paper, scissors]
Your if statement will never really work out. 'com' will end up being one of the the big docstring values you defined, not the string 'rock'
if com == 'rock':
Consider using one variable set for logic, and one for display:
choices = ["rock", "paper", "scissors"]
# get user choice, display a hand symbol for it.
com = random.choice(choices))
# have computer's choice display a hand symbol for it.
# compare user choice and com choice for message about win lose draw.
Upvotes: 0