Ask coding questions

← Back to all posts
calling "define function (def function) for a simple login
OmegaX (0)

Hello everyone
here is my simple code for a simple login :

def Login(username , password):
i = 1
while i<5 :
username = int(input("Enter your username: "))
password = int(input("Enter your password: "))
if username == "Test" and password == "Test123":
return print("Successful Login")
break
else :
return print("username or password is wrong")
i += 1

my question is how can I call it ?

Answered by JoshDaBosh (77) [earned 5 cycles]
View Answer
Commentshotnewtop
JoshDaBosh (77)

First, remove the parameters username and password from line 1:
def Login(username , password): -> def Login():
put this at the bottom of your code:
Login()

Get rid of the return print() statements and just print() first and then just put "return" at the end.