Sololearn: Learn to Code
New course! Every coder should learn Generative AI!
Try a free lesson
+ 5
extend attaches the elements of a sequence to a list, append attaches the sequence as a whole: l = [1, 2, 3] l.extend([4, 5]) l.append([6, 7]) print(l) # [1, 2, 3, 4, 5, [6, 7]] ~~~ l.extend([4, 5]) is pretty much the same as: for element in [4, 5]: l.append(element)
21st Mar 2019, 6:24 AM
Anna
Anna - avatar