1# dict comprehension we use same logic, with a difference of key:value pair
2# {key:value for i in list}
3
4fruits = ["apple", "banana", "cherry"]
5print({f: len(f) for f in fruits})
6
7#output
8{'apple': 5, 'banana': 6, 'cherry': 6}
1{ (some_key if condition else default_key):(something_if_true if condition
2 else something_if_false) for key, value in dict_.items() }