KnowledgeBoat Logo
|

Robotics & Artificial Intelligence

What should be the output of the following program and why?

list_new=[34, "Hi", 56.7, "Hello"] 
list_new.extend(["India", "Happy"]) 
print(list_new) 

Python List Manipulation

3 Likes

Answer

[34, 'Hi', 56.7, 'Hello', 'India', 'Happy']

Working

The extend() function is used to add multiple elements at the end of a list. Here, the elements "India" and "Happy" are added to the existing list list_new as separate elements, not as a single list.

Answered By

2 Likes


Related Questions