Everyone!
I am trying to add a new sublist to an existing list, but I am not quite sure on how to do it. Here is my code:
data = [[4,5],[3,7]]
search = 9
for sublist in data:
if search in sublist:
sublist.append(0)
print("there", sublist)
break
else:
print("not there")
break
def sublist():
[5,6]
print[data]
However, if the search is not there, the sublist does not get added to the original list. How can I do this?
Cheers! 5813
Just append it:
>>> data = [[4,5],[3,7]]
>>> data.append([5,6])
>>> data
[[4, 5], [3, 7], [5, 6]]