Previous

Functions

2 / 6
Next

Function parameters enable functions to be reusable in different contexts.

def login_attempt(username, password):
  if (username == "JohnDoe" and password == "Password123!"):
    print("Access granted")
  else:
    print("Access denied")

When calling this function, you must provide function arguments:

login_attempt("JohnDoe", "password123")
login_attempt("JohnDoe", "Password123")
login_attempt("JohnDoe", "Password123!")
Send

Function parameters

Hint
Beginner

Define a function called repeat with two parameters message and n. The function should print the message exactly n times using a while loop.

Then call the function to print "Hello, world!" five times.

Help
Solve
Reset
Run
Submit
 

Test results

Test result #
Expected output
Your output

Your email has been verified!