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
Moises Miguel
5,028 Pointsquick question
how can i get this game to not repea as much and how can i have it so it gives you 3 chances and than ask if you want to plaa again?
2 Answers
Steven Parker
243,215 PointsThere are several ways to make the game repeat.
But an easy one would be to put the call to game() on the bottom line inside a loop that includes the repeat question:
again = 'y'
while (again == 'y') :
game()
again = input('Do you want to play again (y/n)? ').lower()
I'm not quite sure what you mean about "not repeat as much", though. Since there are only 3 choices, there's a 33% chance it will be the same as last time.
Moises Miguel
5,028 PointsIt just seems repetitive to list them out for every single one. Is there anyway to shorten it?
Steven Parker
243,215 PointsTo list what out? The three choices ([R]ock, [P]aper, [S]cissors)? That seems pretty reasonable.
But if you really hated that, instead of having it in the prompt, you could print it out just one time before the game, and then make the game prompt just be "Pick: ".