Share your repls and programming experiences

← Back to all posts
Rock Paper Scissors
adamspam (3)

I made a simple Rock Paper Scissors hope you enjoy and i am looking for feed back
https://repl.it/@adamspam/Rock-Paper-Scissors

Comments
hotnewtop
paulus36 (4)
  • All the times you put int() on something that is already an integer (int(0) for example) it does nothing, so get rid of it
  • Your naming conventions are weird (human_choice is not a contraction but round_no is), so I would advise you to pick a style and stick with it
  • Instead of manual checking for ties by doing three if statements, you can just check for equality since all ties are when both choices are the same (if human_choice == computer_choice)
  • There is a cool trick in python where x = x - 1 (what you use for the round numbers) can be shortened to x -= 1. It will make your code more readable and more effecient
  • When you check if the user did not put a correct action at the end of the if-statements, since if he did a correct action another one of the ifs would of caught it, you can just turn the ifs into an if ... elif chain, and make the error catching part an else (so that only incorrect things will fall into it) shortening your code further
  • (A bit more advanced) You may of noticed that every time either the computer or the player wins, you have to do the same changes to the wins of each player. What you could do instead is a function that does those changes (e.x. player_win() or computer_win() ) and call that every time so that you only have to code it once (if you are new to python and understood nothing, it's fine, just ignore this)

Good luck with your future adventures in python!

adamspam (3)

@paulus36 I appreciate your help next time I am at school I will try your suggestions

paulus36 (4)

(Additional note) You can also use f-strings to put variables in your print statements (e.x. print(f"The computer has got {computer_win} points.")* which is faster (and in my opinion prettier).
*Note that i took away the str() because (at least in f-strings) it is not necessary to print integers.