Python basic help, please crying

Asked 2 years ago, Updated 2 years ago, 22 views

The IDs of 10 users were given, and their passwords have not yet been designated. As the system is released, each user is asked to enter a password when it is first logged, and from the second login, it supports normal logging by entering the same password as the registered password. This problem outputs the result of Login's success or failure in this way. The program continues to check the ID and password with an infinite loop, and ends when the ID is entered as 'quit'. It's a task. You have to specify a password for each ID, but I have no idea. Give me a hint ㅠ<

print("=============================================================")       

login_list = ["Minsu", "Younghee", "Cheolsoo", "Potato", "Watermelon", "Apple", "Pumpkin", "Octopus", "Puppy", "Cat"] 
psw_list = []
Minsu = 0
while True: #Use true to repeat continuously
    login = input ("Login:") #loginWhere to receive input
    if login in login_list: 
        if login == 0:
            check = input(" setting password Enter  :")
            login +=1

        else:
            password = input ("Please enter your password"). :")
            if check == password:
                print("You have successfully logged in."")
            elif check != password:
                print("You failed to log in."")
    elif login == "quit":
        break; #End repeat statement       
    elif login not in login_list: 
        print("Unable to verify ID verifiable ID")

python

2022-09-22 18:07

1 Answers

Besides the list, there is a data type called dictionary. This data type, also known as hash table, is a key&value type of data, for example, if "Minsu" was an element in the list, "Minsu" in dictionary: "1234", a pair becomes one element. To distinguish whether you need to log in by entering the pw that already exists (pws setting), you can use the dictionary to set the value of each key to {"Minsu" : 0, "Younghee" : 0, ...} and enter the initial pw when if login_list ["Minsu" == 0]. For reference, the value for a specific key can be approached in this way: login_list["Younghee"]. It might be more efficient to search and study Python Dictionary than to explain this and that! It's not a difficult concept at all


2022-09-22 18:07

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.