Vidyalelo
Python · Q49

Python Introduction and basic

Programming · Python · question 49

Q49

To add a new element to a list we use which Python command?

A.
list1.addEnd(5)
B.
list1.addLast(5)
C.
list1.append(5)
Answer
D.
list1.add(5)

Answer: Option C

Solution

Answer: Option C
Solution:
In Python, to add a new element to the end of a list, the append() method is used.
The syntax for using append() is list_name.append(element), where list_name is the name of the list and element is the value to be added.
append() adds the specified element to the end of the list, increasing the list's length by one.
Therefore, list1.append(5) will add the element 5 to the end of list1.