Record#
- Today I learned about def. def is used to define a function that can be repeatedly called in the code.
- The name of a function can consist of alphanumeric characters and underscores, but it cannot start with a number, contain spaces, or be the same as a built-in Python function.
- Pay attention to the indentation of the code within a function. Python is a language that strictly requires proper indentation.
- Use a function to create a user login interface to verify the username and password. Display an error message and prompt for re-entry if there are any errors.
CODE#
print("User Login Page")
print()
def ulogin():
u = ""
p = ""
while True:
u = input("Enter username: ")
p = input("Enter password: ")
if u == "user" and p == "pass":
print("Welcome, user!")
break
else:
print("Incorrect username or password. Please try again.")
continue
ulogin()