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
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.
I merged the
get_user_choice
andget_computer_choice
functions into a single reusableget_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.