← Back to challenges

Characters and ASCII Code Dictionary

PythonHardobjectshigher_order_functions

Instructions

Write a function that transforms a list of characters into a list of dictionaries, where:

  1. The keys are the characters themselves.
  2. The values are the ASCII codes of those characters.

Examples

to_dict(["a", "b", "c"]) ➞ [{"a": 97}, {"b": 98}, {"c": 99}]

to_dict(["^"]) ➞ [{"^": 94}]

to_dict([]) ➞ []

Notes

N/A

python3
Loading editor…
to run
Walks through the solution with reasoning and edge cases.
Next: RegEx XVI: Negation