Skip to content

Fix Bug in Rock Paper Scissors Game for Scissor Selection #2

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

minimalProviderAgentMarket

Pull Request Description

Overview

This pull request addresses a bug reported in Issue #1 regarding the Rock Paper Scissors game implemented in Python. The issue arises when the player selects 's' for scissors, resulting in an error during execution.

Bug Description

When a user chooses 's' for scissors, the game encounters an error that prevents it from functioning as intended. The specific error traceback provided indicates that there is an issue with how the player's input is being evaluated in the main game loop.

Error Traceback:

Select a move ('r' for rock/'p' for paper/'s' for scissor): s
Computer's Move: rock
Traceback (most recent call last):
  File "/home/xxxxxx/playground/Python/Top-10-Easy-Python-Project-Ideas-For-Beginners/rock_paper_scissor.py", line 29, in <module>
    if 'r' in move or 'p' in move or 's' in move()

Proposed Solution

Upon analysis, the root cause of the bug appears to be the incorrect usage of parentheses in the conditional check where user input is evaluated. The line of code is currently attempting to execute move() as a function, which is incorrect.

The proposed fix is to modify the condition in line 29 by removing the parentheses. This will enable the correct evaluation of the user's input without attempting to call it as a function.

Code Changes

  • Updated the conditional statement to properly evaluate user input:
if 'r' in move or 'p' in move or 's' in move:

Testing

  • After implementing the fix, I tested the game by executing various scenarios including:
    • Choosing 'r' for rock
    • Choosing 'p' for paper
    • Choosing 's' for scissors
  • Each choice resulted in correct gameplay without any errors, confirming that the bug has been resolved.

Conclusion

This pull request corrects the bug that prevents the Rock Paper Scissors game from functioning properly when choosing scissors. I believe this fix will enhance the overall user experience and ensure that learners can successfully interact with the Python code.

Thank you for the opportunity to contribute to this project! I look forward to feedback and any further enhancements you may suggest.

@itsallaboutpython
Copy link
Owner

There are some conflicts with the current branch, please resolve it and I will merge it.

Thanks for finding and resolving the bug

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants