-4

I don't understand why this python code does not work, I thought if any of the Usernames were entered it would then proceed to the next indented section.

However my elifs are showing an error of expected indent however, if I indent them they become part of the Frobinson username don't they?

if Username =='Frobinson':
    print('Please input password, the default password will be QWERTY')
    Password=input()
    if Password == 'QWERTY':

elif Username =='Jsmith':
    print('Please input password, the default password will be QWERTY')
    Password=input()
    if Password == 'QWERTY':

elif Username =='Joe':
    print('Please input password, the default password will be QWERTY')
    Password=input()
    if Password == 'QWERTY':


    menu() 
Sayse
  • 42,633
  • 14
  • 77
  • 146
  • 1
    Each of your `if Password == 'QWERTY':` lines should have an indented block underneath it. Without that, your code does not make sense. – khelwood May 24 '19 at 10:57
  • 5
    `if Password == 'QWERTY`': nothing follows those lines and you'll probably get *SyntaxError*s. – CristiFati May 24 '19 at 10:57
  • Possible duplicate of [How to use the pass statement?](https://stackoverflow.com/questions/13886168/how-to-use-the-pass-statement) – Sayse May 24 '19 at 11:06
  • Not a direct duplicate but presumably you haven't yet implemented what logic the password if statement should do – Sayse May 24 '19 at 11:07

2 Answers2

1

Welcome to StackOverflow!

It does not make sense to have an if statement with no body, and will result in a SyntaxError. Based on the code you wrote, I'm guessing you mean to assign a default value for the variable if no input is provided, something like...

if Username =='Frobinson':
    print('Please input password, the default password will be QWERTY')
    Password=input()
    if not Password:
        print('No password supplied.')
        Password = 'QWERTY'

You also appear to have menu() indented on the last line such that it would only trigger for the user named "Joe".

kojiro
  • 74,557
  • 19
  • 143
  • 201
0

I guess this is what you wanted to do:

if Username =='Frobinson':
    print('Please input password, the default password will be QWERTY')
    Password=input()
    if Password == 'QWERTY':
        menu() 
elif Username =='Jsmith':
    print('Please input password, the default password will be QWERTY')
    Password=input()
    if Password == 'QWERTY':
        menu() 
elif Username =='Joe':
    print('Please input password, the default password will be QWERTY')
    Password=input()
    if Password == 'QWERTY':
        menu()