I have a situation where I need to populate a list that is going to be a part of a larger data structure with a series of identical values. Now, in any other programming language I would do it for example like this (let itemIndexes be a list of item indexes):
targetStatusCode = "TC13"
statusCodes = []
foreach itemIndexes:
statusCodes .append(targetStatusCode)
However, in Python, this is apparently not possible.
Instead, I have now settled for this:
targetStatusCode = "TC13"
statusCodes = []
for each in itemIndexes:
statusCodes .append(targetStatusCode)
However, this results in me getting a warning "local variable 'each' is not used anymore".
So, here's my question: Is there an intended "ideal" way to handle this specific sort of situation in python that does not generate a warning?
Explanation why this is not a duplicate of for loop in Python
I already tried the above solution, and it raises the IDE warning I described above. My question was for a "clean" solution that allows me to do this without my IDE raising a "variable is not used anymore"-warning. One of the answers below thankfully provided a working solution for this.