So I have 3 Lists
cie,
itemrange,
pfinal
they are as below
#Note: cie values are integers, but I changed it just so my point gets clear
cie = [[a, b, c, d], [e, f, g, i], [j, k, l, m]]
itemrange = ["1", "2", "3"]
x = []
I have a string as the string contains a function name and an itemrange placeholder
Like so
functionName(1, 2)
I want to replace the
1, 2 into the nested items in
cie and append it to x
Like so
x = [
functionName(a,e) #first item from the first 2 indexes of cie
functionName(b,f)
functionName(c,g)
#and so on...
]
What I have tried:
statement = input()
for i in itemrange:
if i in statement:
for n in cie[int(i) - 1]:
x.append(statement.replace(i, str(n)))
print(x)
This results the following output:
<pre lang="text">
inputText: functionName(1,2)
output:
x =
[
"functionName(0,2)",
"functionName(0,2)",
"functionName(0,2)",
"functionName(0,2)",
"functionName(1,0)",
"functionName(1,0)",
"functionName(1,1)",
"functionName(1,1)",
]
This seems to be a problem with my for loop, as indeed it is replacing the values, but not recursively, how can I do it so it replaces multipl items in itemrange at the same time and stores them at once?