+ 2
ROCK PAPER SCISSORS
I made a rock-paper-scissors program using https://www.onlinegdb.com/ I appreciate any feedbacks, advice on making my code more efficient, and pointing out any useless code. thank you \(ovo) my code(EDITED): https://code.sololearn.com/cQWkb0hwH444/?ref=app
4 Answers
+ 6
In terms of functionality, it is a nice beginner code. It seems to work fine, although unfortunately on the Sololearn platform we cannot use interactivity, so we can only enter all inputs upfront.
Regarding the style I have some comments...
player_score = bot_score = 0
We don't do this, it is generally more readable to initialize each variable on a separate line.
While loop would be more user friendly, so that the player wouldn't have to decide at first, how many games to play.
Also you could simplify the input choices maybe to single character r,p,s because I am sure a lot of random people have difficulity spelling "scissors" :) plus all that typing is a pain.
Taking only "no" as an option to stop, is also not user friendly, maybe take the opposite approach and continue the game only if user says y
There is a lot that could be simplified in your if/else branches, basically there are only 3 possible outcomes (in terms of who won), and the draw is very easy to rule out first.
+ 2
Tibor Santa I really appreciate your advice, ill try to improve my code regarding your comment. Thank you(â§âœâŠ)
0
Hi
0
Hello