CameraIcon
CameraIcon
SearchIcon
MyQuestionIcon
MyQuestionIcon
4
You visited us 4 times! Enjoying our articles? Unlock Full Access!
Question

Consider the following list myList. What will be the elements of myList after the following two operations:
myList = [10,20,30,40]
i. myList.append([50,60])
ii. myList.extend([80,90])

Open in App
Solution

i) append() function takes only one argument and inserts the element to the end of the list. Here, the argument is a list containing the element 50, 60. Therefore, the output will be: [10, 20, 30, 40, [50, 60]]

ii) extend() function takes a list as an argument and appends each element of the list in the same order. The final output will be: [10, 20, 30, 40, [50, 60],80,90]

flag
Suggest Corrections
thumbs-up
2
Join BYJU'S Learning Program
similar_icon
Related Videos
thumbnail
lock
Definition of Function
MATHEMATICS
Watch in App
Join BYJU'S Learning Program
CrossIcon