Day 023 - Project 23 : Subroutine Logins

If you have any questions, comments or issues with this project please post them here!

Ok you might have cracked my earlier login but let’s try a better one :closed_lock_with_key: !

Day 23 of #Replit100DaysOfCode #100DaysOfCode.

1 Like

A question for the Day 22 challenge, specifically regarding the continue command in the solution code. I’m still trying to wrap my head around the break, continue and exit commands. But if my understanding is correct, and that continue just skips any remaining code in the loop for the current iteration, then is it really necessary in this case? I don’t have it in my code, and the program seems to function as expected, but I wanted to check and see if I was missing something.

The code works fine when inputting the correct username and password but when they are wrong it only goes back into the loop instead of looping and giving the “Incorrect Username or Password” password. How do make it so it does both?

You can remove the else branch and the continue keyword entirely. This is because if the user enters everything correctly, it will break, so anything underneath will be unreachable. However, if the user enters anything incorrectly, it will skip ifs and go straight to the print statement.

def login():
  while True:
    User = input("Username?:")
    Pass = input("Password?:")
    if User == "Casian1":
      if Pass == "Casian2":
        print("Welcome to replit!")
    print("Incorrect Username or Password")

Just something to note, it’s recommended to use variable names such as username and password with a lowercase starting letter.

I have a curiosity question with regards to this project. Imagine you have an Identity Management System and you have hundreds of users. Is there a way to write code to call upon checking two columns in a database instead of hardcoding the username and password. I feel doing it this way would be a security risk for users especially if you are lets say a banking app for example.

print("--- Replit Login System ---")

def login():
  while True:
    username = input("What is your username?: ")
    password = input("What is your password?: ")
    if username == "david" and password == "baldies4life":
      print("Welcome to Replit!")
      print("Whoops! I don't recognize that username or password. Try again!")


Well of course, this project is only intended to do basics after all.

You could, how would depend on what database you use.


I think I might be getting ahead of myself here, but will we get to learn how to connect databases in the 100daysofcode challenge or will we have to go out and bridge that gap elsewhere?

You’ll learn how to use ReplitDB.