User and Password Interface Pt. 2 /u/Take-The-L-Train Python Education
User and Password Interface Pt. 2 /u/Take-The-L-Train Python Education
This is a continuation of a post I made earlier. I think I have a better grasp of while loops and if/else statements, but there are still a few kinks in my code.
The code is:
- print(‘Welcome to the USG Ishimura.’) 2.
- user = input(‘Please enter your user ID: ‘)
- print(‘Welcome, ‘ , user) 5.
- while True:
- x = input(‘Please enter your passcode: ‘)
- if x == ‘987413’:
- if user == ‘Isaac Clarke’:
- print(‘Access granted.’)
- break
- else:
- print(‘Access denied. Please try again.’)
- if x == ‘987319’:
- if user == ‘Zachary Hammond’:
- print(‘Access granted.’)
- break
- else:
- print(‘Access denied. Please try again.’)
- if x == ‘987665’:
- if user == ‘Kendra Daniels’:
- print(‘Access granted.’)
- break
- else:
- print(‘Access denied. Please try again.’)
Everything’s working the way that I want it to, but when I put in Zachary Hammond or Kendra Daniels’ username and passcode, the terminal will print out ‘Access denied. Please try again.’ as well as ‘Access granted.’ Basically, both the if and the else statement are printing out at the same time. How can I correct this so only the if or the else statement will print out at once?
submitted by /u/Take-The-L-Train
[link] [comments]
r/learnpython This is a continuation of a post I made earlier. I think I have a better grasp of while loops and if/else statements, but there are still a few kinks in my code. The code is: print(‘Welcome to the USG Ishimura.’) 2. user = input(‘Please enter your user ID: ‘) print(‘Welcome, ‘ , user) 5. while True: x = input(‘Please enter your passcode: ‘) if x == ‘987413’: if user == ‘Isaac Clarke’: print(‘Access granted.’) break else: print(‘Access denied. Please try again.’) if x == ‘987319’: if user == ‘Zachary Hammond’: print(‘Access granted.’) break else: print(‘Access denied. Please try again.’) if x == ‘987665’: if user == ‘Kendra Daniels’: print(‘Access granted.’) break else: print(‘Access denied. Please try again.’) Everything’s working the way that I want it to, but when I put in Zachary Hammond or Kendra Daniels’ username and passcode, the terminal will print out ‘Access denied. Please try again.’ as well as ‘Access granted.’ Basically, both the if and the else statement are printing out at the same time. How can I correct this so only the if or the else statement will print out at once? submitted by /u/Take-The-L-Train [link] [comments]
This is a continuation of a post I made earlier. I think I have a better grasp of while loops and if/else statements, but there are still a few kinks in my code.
The code is:
- print(‘Welcome to the USG Ishimura.’) 2.
- user = input(‘Please enter your user ID: ‘)
- print(‘Welcome, ‘ , user) 5.
- while True:
- x = input(‘Please enter your passcode: ‘)
- if x == ‘987413’:
- if user == ‘Isaac Clarke’:
- print(‘Access granted.’)
- break
- else:
- print(‘Access denied. Please try again.’)
- if x == ‘987319’:
- if user == ‘Zachary Hammond’:
- print(‘Access granted.’)
- break
- else:
- print(‘Access denied. Please try again.’)
- if x == ‘987665’:
- if user == ‘Kendra Daniels’:
- print(‘Access granted.’)
- break
- else:
- print(‘Access denied. Please try again.’)
Everything’s working the way that I want it to, but when I put in Zachary Hammond or Kendra Daniels’ username and passcode, the terminal will print out ‘Access denied. Please try again.’ as well as ‘Access granted.’ Basically, both the if and the else statement are printing out at the same time. How can I correct this so only the if or the else statement will print out at once?
submitted by /u/Take-The-L-Train
[link] [comments] This is a continuation of a post I made earlier. I think I have a better grasp of while loops and if/else statements, but there are still a few kinks in my code. The code is: print(‘Welcome to the USG Ishimura.’) 2. user = input(‘Please enter your user ID: ‘) print(‘Welcome, ‘ , user) 5. while True: x = input(‘Please enter your passcode: ‘) if x == ‘987413’: if user == ‘Isaac Clarke’: print(‘Access granted.’) break else: print(‘Access denied. Please try again.’) if x == ‘987319’: if user == ‘Zachary Hammond’: print(‘Access granted.’) break else: print(‘Access denied. Please try again.’) if x == ‘987665’: if user == ‘Kendra Daniels’: print(‘Access granted.’) break else: print(‘Access denied. Please try again.’) Everything’s working the way that I want it to, but when I put in Zachary Hammond or Kendra Daniels’ username and passcode, the terminal will print out ‘Access denied. Please try again.’ as well as ‘Access granted.’ Basically, both the if and the else statement are printing out at the same time. How can I correct this so only the if or the else statement will print out at once? submitted by /u/Take-The-L-Train [link] [comments]