-
Notifications
You must be signed in to change notification settings - Fork 0
Description
What was done well
-
Clear initialization:
You've correctly set up and initialized variables for scores and rounds at the start of the program. -
Correct loop usage:
Thewhile
loop accurately runs for a fixed number of rounds, ensuring the game has a clear duration. -
Random choice:
The use ofrandom.choice()
is a great way to have the computer pick an option, making the game unpredictable. -
Logical win conditions:
Theif/elif/else
structure correctly checks all the winning, losing, and tie scenarios based on the game's rules. -
Final outcome:
The code correctly determines the overall winner at the end of the game by comparing the final scores.
What could be improved
-
Input validation and sanitization:
The code doesn't check if the user's input is a valid choice (e.g.,"rock"
,"paper"
,"scissors"
).
It is also case-sensitive, so typing"Rock"
would result in a loss.
Using.lower()
on the input would fix this. -
Concise conditional logic:
Theif/elif
statements for checking wins and ties are a bit long.
You could make this more efficient by using a dictionary to store winning combinations, similar to the suggestion in the previous feedback. -
Redundant code:
The lineuser_guess = str(user_guess)