二手产品经理

二手产品经理

THIS IS RENO

Learn Python Online in 100 Days - Week 4 Day 2

Record#

Catbox

  1. Today learned def. def is to define a function, which can be repeatedly called in the code.
  2. The naming of functions can include letters, numbers, underscores, etc., cannot start with a number, cannot have spaces, and cannot be the same as Python built-in functions.
  3. Pay attention to the indentation of the context code of the function. Python is really a language that strictly requires indentation.
  4. Use functions to create a user login interface to verify the username and password. When there is an error, prompt the error and ask for re-entry.

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.