二手产品经理

二手产品经理

THIS IS RENO

Learn Python Online in 100 Days - Week 4, Day 2

Record#

Catbox

  1. Today I learned about def. def is used to define a function that can be repeatedly called in the code.
  2. 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.
  3. Pay attention to the indentation of the code within a function. Python is a language that strictly requires proper indentation.
  4. 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()

Loading...
Ownership of this post data is guaranteed by blockchain and smart contracts to the creator alone.