#๐ ๐ help homework.
42 messages ยท Page 1 of 1 (latest)
@rare frigate
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.
help xd
@rare frigate do you see why this is wrong? else: input_password != admin_pass
an if else looks like this
x = 5
if x == 6:
print("x is 6")
else:
print("x is not 6")```
your else looks like this else: input_password != admin_pass
@rare frigate an else can't have a condition. the else block is for when all prior conditions are false.
yeah
so if the password the user did is not equal to admin_pass then it will reduce his attempts\
i dont see whats wrong
if you check if its equal and its not then you know it must not be equal
whats a condition?
im new to python btw guys
else doenst take anything as an argument
so what should i do instead if !=
something that can be true or false; input_password == admin_pass is the condition for your if statement
so if can have a condition
but else cant
that makes no sense but okay
exactly
it makes tons of sense
the "else" is for if the condition is false
if you want to check more than one condition, you use elif
ok ok fine
user_input = input('enter some text: ')
if user_input.startswith('a'):
print('a!!!')
elif user_input.startswith('b'):
print('b!!!')
else:
print('neither')
thank you guys by thr way!
Oh
okayyy
wait you are right it does make sense
there's no point doing this, though
user_input = input('enter some text: ')
if user_input.startswith('a'):
print('a!!!')
elif not user_input.startswith('a'):
print('no')
you could just use else: because if user_input.startswith('a') is false, then not user_input.startswith('a') is guaranteed to be true
@rare frigate make sense?
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.
๐ help homework.
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.