I am trying to have a user (me) enter specfic data points and it spew out what those data points are based on specific criteria
No matter what I answer the first input with (online or irl are the two answers) it skips over either the last if/elif statement if i say irl, or both the first and last if/elif statement if i say online. please help me figure out where i messed up (I"m stil very new and appreciate this)
#๐ skipping or not doing if/elif statements
18 messages ยท Page 1 of 1 (latest)
@oak chasm
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.
Closes after a period of inactivity, or when you send !close.
for example if i answer the first question "online" it doesnt set the Event_level to "No" and instead just goes straaight to the Yes option
it seems the problem lies in the elif i set up for Event_level Y/N and idk what i did wrong
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.")
oh okay gotcha
!e you can see here
Event_level = "No"
print(bool(Event_level == "Y" or "Yes"))
:white_check_mark: Your 3.13 eval job has completed with return code 0.
True
i swear this gets me so much im so sorry!
Don't be ๐ That's what these help channels are for
thanks still ye
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.