Communities for your favorite technologies. Explore all Collectives
Stack Overflow for Teams is now called Stack Internal. Bring the best of human thought and AI automation together at your work.
Bring the best of human thought and AI automation together at your work. Learn more
Find centralized, trusted content and collaborate around the technologies you use most.
Stack Internal
Knowledge at work
Bring the best of human thought and AI automation together at your work.
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()
I fixed it by putting name = input('Enter a name.\n> ').rstrip() inside of the actual function instead as an argument:
name = input('Enter a name.\n> ').rstrip()
def get_name(): name = input('Enter a name.\n> ').rstrip() return name if validate_length(name, 'name') else get_name()
Add a comment
Required, but never shown
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.
Explore related questions
See similar questions with these tags.