Hi - I'm a rookie programmer. Could somebody explain how I can append a nested list of the form:
List =
[[Name1,[Detail-1,Counter-1],[Detail-2,Counter-2].....]
[Name2,[Detail-1,Counter-2],[Detail-2,Counter-2].....]
................................................. ]
My code is :
def program(List, Name, Detail):
for entry in List:
if entry[0] == Name:
entry[1].append([Detail,Counter])
return
List.append ([Name,[Detail]])
for entry in index:
if entry[0] == Name:
entry[1].append(Counter)
But this shows the List as:
[
[Name1,[Detail-1,Counter,[Detail-2,Counter-2],[Detail-3,Counter-3],.....]
[Name2,[Detail-1,Counter,[Detail-2,Counter-2],[Detail-3,Counter-3],.....]
]
So the problem is with the List index no. n[1][0] which means something is wrong with the highlighted (bold and italicised) block. Could you please look at it?
Any help is highly appreciated.
Thanks