Your question contradicts itself, you want to prompt the user to enter an integer value that would in return, create that many values available for use. Just a note on:
…make python create variables, without the user creating the variables?
You’re creating the values using python, so indirectly, python is creating them, the user is entering how many values he/she wants using a python program, so indirectly, the user is also creating them.
With that being said, a list will suffice for this:
num_of_vars=int(input("Enter number of int variables you want to create:")) vals= * num_of_vars print(vals)
input() function prompts the user it’s argument, i.e , the string “Enter number of int variables you want to create.” However, this needs to be treated as an integer value. So we explicitly convert it using
vals is initialized with
num_of_vars elements (input of user) all with the value of 0. So if we input 5 and print this list out, we get:
[0, 0, 0, 0, 0]
Python created variables without the user creating them.
However, if you actually mean to write the “variables” in code, then that’s entirely different, and can be done with nothing more than the
input() function, python input and output and a ton of boredom.
Hope this helped!