0

Hi I'm working on a login app in python, and i wrote this function:

def register_login():
    user_choice = input(print("Would you like to login or register?"))
    user_choice.lower()
    if user_choice == "login":
        print("You will be redirected to the login window.")
    elif user_choice == "register":
        print("You will be redirected to the registration window.")

But whenever i call this function the message gets printed with the value None under it. Is there a way to get rid of the None message?

riccio01
  • 5
  • 5
  • There must be more to it? How are you calling register_login? – Lewis Morris Aug 23 '20 at 17:26
  • Yes there is, I would like to say that I'm a total newbie to programming and this is my first training project. I know that the naming is not very accurate. – riccio01 Aug 23 '20 at 17:28
  • Yes there is. Do not call it with `print(register_login())` your function returns nothing so it returns None implicitly See [this](https://stackoverflow.com/a/28812883/7505395) answer of the dupe. – Patrick Artner Aug 23 '20 at 17:30

1 Answers1

0

I guess you are calling it like this

print(register_login()) because register_login() returns None.

You could return the values and print it like this.

def register_login():
    user_choice = input(print("Would you like to login or register?"))
    user_choice.lower()       
    if user_choice == "login":
        return "You will be redirected to the login window."
    elif user_choice == "register":
        return "You will be redirected to the registration window."

print(register_login())

Alternatively just call it with out the print()

register_login()

Side note - this line does nothing.

user_choice.lower()

you would want to replace it with.

user_choice = user_choice.lower()

or

user_choice = input("Would you like to login or register?").lower()
Lewis Morris
  • 1,916
  • 2
  • 28
  • 39