Printing block in 'else' statement regardless of input (SCHOOL ASSIGNMENT)

Question:

Current behavior:

Desired behavior

Repl link:
https://replit.com/@formii-2023-24/Magical-Pet-Rand0MnAm3

print("Are you scared of multi-legged creatures with 3 through (not 4) infinity legs?")
input("Enter 'yes 1' or 'no 1':  ")
yes_1 = True
no_1 = False

print("Do you like crabs?")
input("Enter 'yes 2' or 'no 2': ")
yes_2 = True
no_2 = False

print("Do you like chamelions?")
input("Enter 'yes 3' or 'no 3': ")
yes_3 = True
no_3 = False

print("Do you like anteaters?")
input("Enter 'yes 4' or 'no 4': ")
yes_4 = True
no_4 = False

print("Do you like Polar Bears?")
input("Enter 'yes 5' or 'no 5': ")
yes_5 = True
no_5 = False

if no_1 and yes_2 and yes_3 and yes_4 and yes_4:
    print(
        "You should get a Wyoming Toe Snatcher! This amazing creature steals the toes"
        " painlessly and completely blood-free off peoples feet while they sleep. He"
        " does it at night because he's nocturnal."
    )
elif no_1 and yes_2 and yes_3 and no_4 and no_5:
    print(
        "You should get an Ohio Toe Snatcher, which does the same things as the Wyoming"
        " Toe Snatcher, except that it is not nocturnal!"
    )
elif yes_1 and no_2 and no_3 and yes_4 and yes_5:
    print(
        "You should get an Abominable Snowman! Just make sure you have a snowcone"
        " machine otherwise it will eat you instead of snowcones! Great cuddling pet"
        " and good for big families!"
    )
elif yes_1 and no_2 and yes_3 and no_4 and yes_5:
    print(
        "You should get a Chameliobear! It changes colors when it roars and likes fresh"
        " swordfish steaks! Won the Magical Creature Hide and Seek World Championships"
        " 376 times in the running!"
    )
elif yes_1 and no_2 and no_3 and yes_4 and no_5:
    print(
        "You should get a talking anteater! It will impersonate the most annoying"
        " person you know, and if you show them the person you are most annoyed by, the"
        " talking anteater will suddenly run over to them and never leave their side!"
        " It will turn into your most annoying friends pet. Great for mending"
        " relationships, as it will take the form of the other person's favorite"
        " animal!"
    )
elif no_1 and yes_2 and no_3 and no_4 and yes_5:
    print(
        "You should get a Polar Crab that shoots ice from its mouth! Great for making"
        " ice-skating rinks on the go!"
    )
elif yes_1 and no_2 and yes_3 and yes_4 and no_5:
    print(
        "You should get a long-nose dragon! This thing is HUGE and will guard you and"
        " your family at any cost. If you got this one, you are super lucky! Only"
        " problem - it doesn't shoot fire out of its mouth. But, its still the best"
        " option! Good job!"
    )
else:
    print("Get a life")

Can you provide us with the code you’re using, any inputs and what it outputs so we can help you debug? We can’t give you the exact answer since it is a school assignment but we can help.

https://replit.com/@formii-2023-24/Magical-Pet-Rand0MnAm3#main.py

1 Like

Sorry but we can’t use that link, as it’s private because it’s in an EDU team.

Can you copy and paste the code here?

1 Like

Sure thing! Do you want me to just copy the link or the entire code?

Just copy and paste the code.

print("Are you scared of multi-legged creatures with 3 through (not 4) infinity legs?")
input("Enter 'yes 1' or 'no 1':  ")
yes_1 = True
no_1 = False

print("Do you like crabs?")
input("Enter 'yes 2' or 'no 2': ")
yes_2 = True
no_2 = False

print("Do you like chamelions?")
input("Enter 'yes 3' or 'no 3': ")
yes_3 = True
no_3 = False

print("Do you like anteaters?")
input("Enter 'yes 4' or 'no 4': ")
yes_4 = True
no_4 = False

print("Do you like Polar Bears?")
input("Enter 'yes 5' or 'no 5': ")
yes_5 = True
no_5 = False

if no_1 and yes_2 and yes_3 and yes_4 and yes_4:
    print(
        "You should get a Wyoming Toe Snatcher! This amazing creature steals the toes"
        " painlessly and completely blood-free off peoples feet while they sleep. He"
        " does it at night because he's nocturnal."
    )
elif no_1 and yes_2 and yes_3 and no_4 and no_5:
    print(
        "You should get an Ohio Toe Snatcher, which does the same things as the Wyoming"
        " Toe Snatcher, except that it is not nocturnal!"
    )
elif yes_1 and no_2 and no_3 and yes_4 and yes_5:
    print(
        "You should get an Abominable Snowman! Just make sure you have a snowcone"
        " machine otherwise it will eat you instead of snowcones! Great cuddling pet"
        " and good for big families!"
    )
elif yes_1 and no_2 and yes_3 and no_4 and yes_5:
    print(
        "You should get a Chameliobear! It changes colors when it roars and likes fresh"
        " swordfish steaks! Won the Magical Creature Hide and Seek World Championships"
        " 376 times in the running!"
    )
elif yes_1 and no_2 and no_3 and yes_4 and no_5:
    print(
        "You should get a talking anteater! It will impersonate the most annoying"
        " person you know, and if you show them the person you are most annoyed by, the"
        " talking anteater will suddenly run over to them and never leave their side!"
        " It will turn into your most annoying friends pet. Great for mending"
        " relationships, as it will take the form of the other person's favorite"
        " animal!"
    )
elif no_1 and yes_2 and no_3 and no_4 and yes_5:
    print(
        "You should get a Polar Crab that shoots ice from its mouth! Great for making"
        " ice-skating rinks on the go!"
    )
elif yes_1 and no_2 and yes_3 and yes_4 and no_5:
    print(
        "You should get a long-nose dragon! This thing is HUGE and will guard you and"
        " your family at any cost. If you got this one, you are super lucky! Only"
        " problem - it doesn't shoot fire out of its mouth. But, its still the best"
        " option! Good job!"
    )
else:
    print("Get a life")

You always set yes_<number> to true and no_<number> to false, no matter what the user answered. Try using if statements to change the values of yes_<number> and no_<number>

an example of how to get input:

is_cool = input("You finished your homework?")
# if the first letter of the input was 'y'...
if is_cool[0].lower() == "y":
    print("yay")
else:
    print("do it!")

How you’re doing it, the inputs are completely unused as they’re not even being assigned to a variable

1 Like

Would cause an error if the user didn’t input any characters, also you defined is_question but used is_cool

is_cool = input("You finished your homework?")
# if the input starts with 'y', regardless of if the letter was capital
if is_cool.lower().startswith("y"):
    print("yay")
...
2 Likes

Thank You guys so much!

Hey @Rand0MnAm3!

Please mark the post that helped you most as the solution so people with the same issue can easily find the solution.

Could you show me an example of this code?

UMAR and I already provided examples.

Use our code as a starting point, and change it to fit with your assignment.

I have to use conditionals.

Okay, use conditionals, but we can’t provide the complete code for you. It’s your assignment that you need to complete.

Yeah, that’s true. Thank you guys for the help!

Again, please mark a post as the Solution.

1 Like