Python Forum
Please help me with my Bootcamp Homework...
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Please help me with my Bootcamp Homework...
#8
Thanks Yoriz. I am unable to get the credential check to turn up positive results. It loops through and then ends with "Login failed" even when I enter root, toor which is in adminList.

# Administrator accounts list
adminList = [
    {
        "username": "DaBigBoss",
        "password": "DaBest"
    },
    {
        "username": "root",
        "password": "toor"
    }
]

# Build your login functions below
# creates a function called getCreds with no paramaters
def getCreds():
    #Prompts user for their username and password
    username = input("What is your username? ")
    password = input("What is your password? ")

    #Dictionary that retains username and password 
    userInfo = [
        {
            "username" : str(username), 
            "password" : str(password)
        }
    ]
    #Return userInfo
    return userInfo

user_info = getCreds()

def checkLogin(user_info, adminList):
    
    if user_info in adminList:
        loggedIn = True

    else: 
        loggedIn = False

    while loggedIn == False:
        print("Login Failed. ")
        retry = getCreds()
        return retry

getCreds()

checkLogin(user_info, adminList)
No errors but not doing the loop correctly. Here is the output:
Output:
What is your username? root What is your password? toor What is your username? root What is your password? toor Login Failed. What is your username? root What is your password? toor
Reply


Messages In This Thread
RE: Please help me with my Bootcamp Homework... - by km3 - Apr-15-2019, 11:52 PM

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020