Skip to content

🐛 [Bug]: Fix unwanted object reference output and improve code structure in Rock Paper Scissors game #499

@yuvraj-k-singh

Description

@yuvraj-k-singh

📝 Description

The Rock Paper Scissors game prints the object reference at the end of execution instead of displaying meaningful output. This happens because print(game) is called without defining a __str__() method inside the Rock_Paper_Scissor class.

Additionally, there are some code quality and logic issues:

  • random is imported inside the method instead of globally.
  • The class name uses incorrect naming convention (Rock_Paper_Scissor instead of Rock_Paper_Scissors).
  • rounds_played increments before a valid round is completed.

🔄 Steps to Reproduce

  1. Go to rock_paper_scissors.py

  2. Run the script using:

    python rock_paper_scissors.py
  3. Play the game and exit by entering no

  4. Observe the output after the game ends

🎯 Expected Behavior

The program should end cleanly without printing the object memory reference. It should only display the final game statistics and save confirmation.

❌ Actual Behavior / Error Logs

The program prints an unwanted object reference like:

<__main__.Rock_Paper_Scissor object at 0x000001F3A2C7B550>

💻 Environment

  • OS: Windows 11
  • Python Version: 3.10.x
  • File Name: rock_paper_scissors.py

  • I am a registered GSSoC 2026 contributor.
  • I want to be assigned to fix this issue.

@steam-bell-92 I’m interested in working on this issue as part of GSSoC 2026. Please assign it to me if it’s available. Thank you!

Metadata

Metadata

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions