Back to Lesson

List-to-Dictionary Sequence

Generate key representations on the fly leveraging data iterators.

Instructions

  • Given a raw list of strings
    words = ["apple", "bat", "car"]
    .
  • Map each word to its string length dynamically.
  • E.g.:
    {"apple": 5, "bat": 3}
    ... Use a dictionary comprehension over the list!
  • Print the result.
main.py
main.py