It's simple, but I have a question. Failed to compare numeric passwords

Asked 2 years ago, Updated 2 years ago, 17 views

usernames = ['a','b','c','d','e']
passwords = ['aa','bb','cc','dd','ee']

passwords = tuple(passwords)

id = input ("Please enter your ID")
pw = input ("Please enter password: ")

if id == usernames[0] and pw ==passwords[0]:
  print ('success')
else:
  print ('Failure")

If you receive a and aa, it says success

usernames = ['a','b','c','d','e']
passwords = [1,2,3,4,5]

passwords = tuple(passwords)

id = input ("Please enter your ID")
pw = input ("Please enter password: ")

if id == usernames[0] and pw ==passwords[0]:
  print ('success')
else:
  print ('Failure")

If we get a and 1 here, do we say that we failed?

Is it because the numbers in the passwords are numbers?

How should I change it to say success when it's a number?

python

2022-09-21 11:41

1 Answers

Modify passwords=[1,2,3,4,5] to passwords=['1','2','3','4','5']


2022-09-21 11:41

If you have any answers or tips


© 2025 OneMinuteCode. All rights reserved.