lundi 18 avril 2016

How to compare a user input variable modified with strings in Python elseif?

Below is the code i am trying to run .

I need the code to display access granted if the password is equal to name or password=name123

However i cannot get it to work .

Please help as i am a newbee on Python

print ('Please enter your username')
name = input()
print ('Please enter your password')
password = input ()
if name == password:
print ('Hello ' + str(name) + ' , Access Granted')
elif password == str(str("name") + '123'):
print ('Hello ' + str(name) + ' , Access Granted')
else:
print ( 'Sorry Access Denied')

Aucun commentaire:

Enregistrer un commentaire