-1

I want to store a python function which has an input function [eg: a = input("Item number: ")], into a variable.

So when I call that variable, it should initiate the main function stored in it.

I tried to make a sample function:

  1. Which takes input from a user and returns it.
  2. Stored that function into a variable, let's say x.
    def user_input():
        item_number = input("Item number: ")
        return item_number
    x=user_input()

-Now when I'm calling that variable x, it is returning the value which was given to the function as input.

-What I want is, it should initiate the function stored in it and ask the user for input.

1 Answers1

0

Try doing it like -

def user_input():
    item_number = input("Item number: ")
    return item_number
x=user_input
#when want to call the function 
y = x()
anuragal
  • 3,024
  • 19
  • 27