Ayu-hack / Hacktoberfest2024-1

This is repo to create some pull requests and completing hacktoberfest 2024 easily. All request will be accepted. Genuine Pull Request will promoted also. #hacktobefest #hacktobefest2024 #hacktobefest-accepted Resources
46 stars 467 forks source link

Update Rock-Paper-Scissors.py by merging functions, simplifying logic, and reducing code redundancy #168

Closed Maryam0330 closed 1 month ago

Maryam0330 commented 1 month ago

I merged the get_user_choice and get_computer_choice functions into a single reusable get_choice function, which helps eliminate redundancy. To simplify the outcome determination, I used a dictionary to map each choice to the one it beats, reducing multiple conditional checks. I also streamlined the game loop to directly check if the player wants to play again, eliminating the need for an additional prompt. Finally, I condensed the output statements so that the game result and both choices are displayed in one line for better clarity.