Lists: keep things together
A list stores items in order and can be changed. Indexes start at 0, so items[0] is the first item. append() adds one item at the end. A slice like items[:2] takes the first two.
हिन्दी में समझें
लिस्ट क्रम से मान रखती है और बदली जा सकती है। इंडेक्स 0 से शुरू है। append() अंत में मान जोड़ता है। items[:2] पहले दो मान देता है।
अभ्यास: fruits में "orange" जोड़ें और बदली लिस्ट प्रिंट करें।
Hinglish mein samjhein
List mein items order mein rehte hain. Counting 0 se shuru hoti hai. append() end mein item jodta hai. items[:2] pehle do items deta hai.
Practice: fruits mein "orange" append karo aur updated list print karo.
A small Python example
fruits = ["mango", "apple"]
fruits.append("banana")
print(fruits[0])
print(fruits[:2])The browser playground runs real Python with Pyodide. Use sample variables instead of interactive input(). Browser package support differs from desktop Python.
Try this example in the Python playground →Practise this idea
Append "orange" to fruits and print the updated list.
Check answer & explanation
fruits = ["mango", "apple"]
fruits.append("banana")
print(fruits[0])
print(fruits[:2])
fruits.append("orange")
print(fruits)append() adds one item to the end of a mutable list. Printing the list lets you verify that orange was added.
Stuck in the course? Choose Check answer for either the challenge or quiz. Read the explanation and continue to the next lesson at your own pace.
Check your understanding
What is the first index?
Check the quiz answer
0
Python starts indexing at 0. -1 refers to the last item.
References & corrections
Use the official Python documentation for full language rules. Read how these lessons are made and checked. Found a mistake? Report it to Excel Keys with this lesson URL and a reproducible example.