#๐Ÿ”’ Absolute beginner here. Can't figure out what I did wrong

10 messages ยท Page 1 of 1 (latest)

finite bluff
#

I made a rock paper scissor bot and it is supposed to tell you game over if you do a wrong input but whatever I type the bot will just continue ignore the else at the very bottom. Probably a silly mistake lol.

import random


rock = '''
    _______
---'   ____)
      (_____)
      (_____)
      (____)
---.__(___)
'''

paper = '''
    _______
---'   ____)____
          ______)
          _______)
         _______)
---.__________)
'''

scissors = '''
    _______
---'   ____)____
          ______)
       __________)
      (____)
---.__(___)
'''

weapon = ["rock", "paper", "scissors"]




print("Welcome to the\nRock Paper Scissors game\n")
choice = input("Choose between\nrock\npaper\nscissors\nType here: ")
if choice == "rock" or "paper" or "scissors" :
    if choice == "rock":
        print(f"You chose:\n {rock}")
    elif choice == "paper":
        print(f"You chose:\n {paper}")
    elif choice == "scissors":
        print(f"You chose:\n {scissors}")
    print("The bot will now choose")

    bot_choice = random.choice(weapon)
    if bot_choice == "rock":
        print(f"The bot chose:\n {rock}")
    elif bot_choice == "paper":
        print(f"The bot chose:\n {paper}")
    else:
        print(f"The bot chose:\n {scissors}")

    if choice == "rock" and bot_choice == "rock":
        print("It's a draw")
    elif choice == "rock" and bot_choice == "paper":
        print("You lose")
    elif choice == "rock" and bot_choice == "scissors":
        print("you win")
    elif choice == "paper" and bot_choice == "rock":
        print("you win")
    elif choice == "paper" and bot_choice == "paper":
        print("It's a draw")
    elif choice == "paper" and bot_choice == "scissors":
        print("You lose")
    elif choice == "scissors" and bot_choice == "rock":
        print("You lose")
    elif choice == "scissors" and bot_choice == "paper":
        print("you win")
    elif choice == "scissors" and bot_choice == "scissors":
        print("It's a draw")


else:
    print("You cant even type what is written in front of you lmao\nGame over buddy.")
solid schoonerBOT
#

Hey @finite bluff!

Please edit your message to use a code block

Add a py after the three backticks.

```py
print('Hello, world!')
```

This will result in the following:

print('Hello, world!')```
solid schoonerBOT
#

@finite bluff

Python help channel opened

Remember to:

  • Ask your Python question, not if you can ask or if there's an expert who can help.
  • Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
  • Explain what you expect to happen and what actually happens.

:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.

serene swan
#

!or-gotcha

solid schoonerBOT
#
The or-gotcha

When checking if something is equal to one thing or another, you might think that this is possible:

# Incorrect...
if favorite_fruit == 'grapefruit' or 'lemon':
    print("That's a weird favorite fruit to have.")

While this makes sense in English, it may not behave the way you would expect. In Python, you should have complete instructions on both sides of the logical operator.

So, if you want to check if something is equal to one thing or another, there are two common ways:

# Like this...
if favorite_fruit == 'grapefruit' or favorite_fruit == 'lemon':
    print("That's a weird favorite fruit to have.")

# ...or like this.
if favorite_fruit in ('grapefruit', 'lemon'):
    print("That's a weird favorite fruit to have.")
serene swan
#

^ your first if-condition has that issue.

finite bluff
#

Oh I see thanks a lot!

#

!close

solid schoonerBOT
#
Python help channel closed with !close

This help channel has been closed. Feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.