QUESTION 1 OF 15

When should you use a list instead of a tuple?

Reveal the answer and explore the explanation.

01
EasyCore

When should you use a list instead of a tuple?

Answer
Answer

Mutable ordered collection supporting indexing and duplicates.

Practical example

Append a new training example without recreating the collection.

PythonRelated concept example
from collections import Counter
words = ['ai', 'ml', 'ai']
counts = Counter(words)
print(counts['ai'])  # 2

Counter is a dictionary-like frequency collection.

Reference: Further reading ↗

Last 30 min revisionHigh-yield interview Q&As