Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Python

Rock paper scissors game

I'm making a rock paper scissors game and i was wondering if you would use elif statements for the choosing who wins for example would you use: elif( userGuess = 'rock' and computerGuess = 'scissors'): print ('user wins')

1 Answer

You're comparison should look something like this I'd say:

if userGuess == computerGuess:
    print("Tie")
elif userGuess == 'rock':
    if computerGuess == 'paper':
        print("You lose")
    else:
        print("You win")
elif userGuess =='paper':
    if computerGuess == 'rock':
        print ("You win")

You can finish that code if you want but that would be my suggestion for you as a beginner. In this code you only have your if statements nested once so that's fine.

Also, you should probably lowercase or uppercase userGuess and computerGuess right before this if/elif/else statement to make comparisons easy.