List comprehensions

for x in y_train:
    x.append(element)

example:

>>> listOfLists = [[1,2], [2,3], [4,5]]
>>> for x in listOfLists:
...     x.append(2)
>>> listOfLists
[[1, 2, 2], [2, 3, 2], [4, 5, 2]]

Browse More Popular Posts

Leave a Comment