I have a question. So I want to use the input()
function in python, but whatever variable you input in the input when it runs, I want to be assigned as a variable and then you can use it as a calculation later. For example,
variable = input("What is your model? ")
array = [1,2,3,4]
k1234 = array[0]
math = str(variable) + 5
That's just a simple example of what I am trying to do. But when I run it, and when I get the prompt: "What is your model?", I type in k1234 but then when it tries to do the math calculation it throws me the error:
ValueError: invalid literal for int() with base 10: 'k1234'
In total, I basically have an array of 20 - 25 values, and have a variable assigned to each of the indices separately in the array, but when you type the variable in the input section, it doesn't recognize it as a integer later on and can't perform the calculation. Anyone have any suggestions? I don't have much experience with input().
Edit: The question "How can I read inputs as integers?" doesn't quite answer my question. I'm trying to get a function that you put a string into the input, will recognize the string as a variable that is defined later on to then be recognized as an integer which you can then use as a calculation later on. :)