I have a list where one of the elements is a variable and it can take a value between 60 to 120.
[0, 1, 2, 3, 4, v]
if I want to print this list for v ranges from 60 to 120:
for v in range(60,121):
print([0, 1, 2, 3, 4, v])
gives the expected result. However if I assign this list to a variable such as:
l = [0, 1, 2, 3, 4, v]
I get an error, because v is undefined. If I try assigning an initial value to v, then declare the list, I do not get an error anymore, but I get stuck with a list where v has already assigned a value:
v = 60
l = [0, 1, 2, 3, 4, v]
for v in range(60,121):
print(l)
always yields [0, 1, 2, 3, 4, 60].
The reason I am trying to assign this list to a variable is, I use this list in many locations in a way longer script, and I need to do a for loop for certain calculations using this list for the range 60 to 120 for v. One solution is typing the list every time it needs to be used, but that requires me to replace all occurrences of this list in the script if I need to change any other list element.
I think my question is: is there a way to assign a list that contains a variable (v) as an element to a variable (l) to be used throughout your script?
Is there a good programmatical way to handle something like this?