#๐Ÿ”’ Password and user

28 messages ยท Page 1 of 1 (latest)

green bone
#

Exactly what I want to know is why it's giving me an error
I'm trying to like set a password and if the user types anything wrong it would say Incorrect
I'm a beginner

glass dirgeBOT
#

@green bone

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.

fallen shuttle
#

damn idk what the bot command is

#

python uses indentation to determine how the code is supposed to run

green bone
#

What's indention

fallen shuttle
#
if a == 5:
  print('wow')
else:
  print('a is not 5 :(')
#

you can see the print statements have an extra tab (i.e. an extra indentation level) compared to the if/else parts

#

that tells python that they go inside the if/else branches

green bone
#

But I forgot how to

#

Like make It connected to

#

Under it

#

?

rich abyss
#

Yeah, that's how you make it connected, by putting the spaces on everything that you only want to run if the condition is true. In your case, that's the print("Correct")

#

Additionally, something you confused is the equality syntax

#

Instead of if Password: (13131), you want if Password == 13131:

#

Finally, this code probably won't work how you want it to, because you aren't getting any user input. Do you know how to do that?

#

@green bone ^

green bone
#

I'm reafing

#

But thanks

rich abyss
#

||py password = int(input("Try a password: ")) if password == 13131: print("Correct") else: print("Incorrect")||

rich abyss
green bone
#

Thanks so much

green bone
rich abyss
#

The same way, ask for an input, check if it's the one you want and only let them keep going if that happens

#

Try it out, if you need help, feel free to ask

#

I'm not sure I'll be able to respond, but someone surely will

glass dirgeBOT
#
Python help channel closed

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.