0

How can I get input to only evaluate when my function is called, not when my app runs?

    def get_name(name = input('Enter a name.\n> ').rstrip()):
    '''Enter a name'''

    return name if validate_length(name, 'name') else get_name()

1 Answer 1

1

I fixed it by putting name = input('Enter a name.\n> ').rstrip() inside of the actual function instead as an argument:

def get_name():
    name = input('Enter a name.\n> ').rstrip()
    return name if validate_length(name, 'name') else get_name()
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.