HomeInterview QuestionsHow do you add some values to a list in Python?

How do you add some values to a list in Python?

🟢 Easy Coding Fresher level
1Times asked
Apr 2026Last seen
Apr 2026First seen

💡 Model Answer

In Python, you can add values to a list using the append() method, the extend() method, or by concatenation. For example:

my_list = []

my_list.append(1) # adds a single element

my_list.extend([2, 3]) # adds multiple elements

my_list += [4] # another way to extend

print(my_list) # [1, 2, 3, 4]

append() runs in amortized O(1) time, while extend() and concatenation run in O(k) where k is the number of elements added.

This answer was generated by AI for study purposes. Use it as a starting point — personalize it with your own experience.

🎤 Get questions like this answered in real-time

Assisting AI listens to your interview, captures questions live, and gives you instant AI-powered answers on a discreet on-screen overlay.

Get Assisting AI — Starts at ₹500