#๐ Else shows up when i use insert if,
45 messages ยท Page 1 of 1 (latest)
@plucky forum
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.
heres what i mean
U can remove if keyword and replace with elif in line no 8
Sorry to ask but what is elif? and whats its purpose
only when the if statement is false it jumps to elif condition
@plucky forum run this ```py
a=int(input("enter: "))
b=int(input("enter: "))
c=int(input("enter: "))
if a<b:
print(" a lesser")
elif b<c:
print("b lesser")
else:
print("ok")
and replace elif with if and see the difference
Oh okay i'll try it out Thanks
Each if/elif/else block is made ofpy if condition: 'Exactly one if.' elif some_other_condition: 'Zero or more elifs.' else: 'Zero or one else.'In that order. The first condition to be satisfied is the only clause to have its indented section run.
Once you deindent with something that isn't an elif or an else, you're terminating the current if/elif/else block.
So another if starts another if/elif/else.
u forgor print function
I didn't.
Yes.
!e py if 'some condition': ... ... elif 'some other condition': ...
yea it worked I never thought of this
:x: Your 3.12 eval job has completed with return code 1.
001 | File "/home/main.py", line 4
002 | elif 'some other condition':
003 | ^^^^
004 | SyntaxError: invalid syntax
cool
At the second ... we're still syntactically valid.
But then we hit the elif.
Which at this point is an elif without an if.
it is like if else if?
elif stands for else if.
i.e. If none of the above conditions are satisfied, but this condition is...
hmm
Then else, if used, coming last, if none of the above conditions are satisfied, do this.
yes
@lilac spoke since how many years u are learning python
Approximately eight to nine years.
alr cya I need to earn way more things
Just take it a step at a time.
I am watching a 100 days playlist daily 1 topic
Avoid burnout.
Good.
This help channel has been closed and it's no longer possible to send messages here. If your question wasn't answered, 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.