Predict List Indexing
Predict Output Easy
Question
What does this code print?
Code
fruits = ["apple", "banana", "cherry"]
print(fruits[0])
print(fruits[-1])
Hint
Negative indices count from the end.
Explanation
fruits[0] is the first element 'apple'. fruits[-1] is the last element 'cherry' (negative indices count from the end). The output is two lines: apple and cherry.
Related Resources
Related Lessons
- Lists
List indexing.
Look up unfamiliar terms
A beginner-friendly glossary explains jargon in plain English — variables, functions, DOM, Promise, and more.
Decode error messages
Plain-English explanations of common errors — what they mean, why they happen, and how to fix them.
Build real projects
Apply what you learned by building guided projects with starter code and solutions.