ROCK PAPER SCISSORS | Sololearn: Learn to code for FREE!
¡Nuevo curso! ¡Todo programador debería aprender IA Generativa!
Prueba una lección gratuita
+ 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

29th Oct 2022, 9:24 AM
CodeEater
CodeEater - avatar
4 Respuestas
+ 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.
29th Oct 2022, 10:00 AM
Tibor Santa
Tibor Santa - avatar
+ 2
Tibor Santa I really appreciate your advice, ill try to improve my code regarding your comment. Thank you(≧▽≦)
29th Oct 2022, 10:04 AM
CodeEater
CodeEater - avatar
0
Hi
30th Oct 2022, 2:15 PM
MD Atikur
MD Atikur - avatar
0
Hello
30th Oct 2022, 9:52 PM
CodeEater
CodeEater - avatar