InfoparkDailyCAREER TOOLS

Python · Lesson 6 of 9

Lists, tuples, sets & dicts

Python's four everyday collections and list comprehensions.

  • list [ ] — ordered and changeable: append(), remove(), sort(), indexing.
  • tuple ( ) — ordered but fixed; good for values that belong together, like (lat, lng).
  • set { } — unique items, no order; fast membership checks and de-duplication.
  • dict {key: value} — look up values by key, like a mini database record.

List comprehensions

A compact way to build a new list: [expression for item in items if condition].

Try it yourself

Press Run to see the output.

Edit and press Run (or Ctrl/⌘ + Enter). Python runs in your browser — the first run downloads the Python engine and takes a few seconds.

Key points

  • list = ordered & editable; tuple = fixed.
  • set removes duplicates.
  • dict.get(key, default) avoids KeyError.

Quick check

Which collection automatically removes duplicates?

Practice task

Make a dict that counts how many times each skill appears in ["sql", "python", "sql", "excel", "sql"].

Interview corner

List vs tuple — when would you use each?

Use a list for a collection that will change (add/remove). Use a tuple for a fixed group of values, as a dictionary key, or to signal that the data should not be modified.

What happens if you read a missing key from a dict?

dict[key] raises KeyError. Use dict.get(key, default) or check with 'key in dict' first.

Further reading

Official documentation, linked for deeper study. These are outside sites; this lesson's text is our own.

Original lesson written by the InfoparkDaily team · © 2026 InfoparkDaily · Free to learn — no paid course or subscription.