Computer Science, asked by royanubhab89, 12 hours ago

To insert the string ‘snake’ to the third position in zoo, which of the following statement is used? a. zoo.insert(3, ‘snake’)
b. zoo. insert(2, ‘snake’)
c. zoo.add(3, ‘snake’)
d. zoo.append(3, ‘snake’)​

Answers

Answered by ndsharma843
0

Answer:

a)

Explanation:

mark me Brainliest please

Answered by varshamittal029
0

Answer: Option (b) is correct.

Concept:

The insert() method adds a new element to the list at the index provided.

Find:

How to insert the string ‘snake’ to the third position in 'zoo' list.

Solution:

The syntax of the insert() method:

list.insert(i, item)

At the ith index, 'item' is inserted into the list. After 'item', all elements are relocated to the right.

Option (b) is correct.

Index 2nd will represent the third position of the list therefore the correct statement will be zoo.insert(2,'snake')

Option (a) is incorrect.

Index number 3 will represent the fourth position of the list therefore item will get added to the fourth instead of the third position.

Option (c) is incorrect.

add( ) method is not used in lists.

Option (d) is incorrect.

The append() method adds a new element to the list's end.

Similar questions