#C14675. String Lengths Dictionary
String Lengths Dictionary
String Lengths Dictionary
Given a list of strings, your task is to construct a dictionary (or map) where each key is a string from the list and its corresponding value is the length of that string.
For example, if the input list is ['apple', 'banana', 'cherry'], the output should be {'apple': 5, 'banana': 6, 'cherry': 6}
.
Note: The output format should exactly match the example, with keys enclosed in single quotes, separated by commas, and the entire dictionary enclosed in curly braces.
In mathematical notation, if S is the set of strings then the function (f: S \to \mathbb{N}) is defined as (f(s)=|s|), where (|s|) represents the length of string s.
inputFormat
The first line of input contains an integer (n) representing the number of strings. The next (n) lines each contain one string. Note that a string may be empty.
outputFormat
Output the dictionary representation of the input strings and their lengths in a single line. The format should be as follows: {'string1': length1, 'string2': length2, ...}
.## sample
3
apple
banana
cherry
{'apple': 5, 'banana': 6, 'cherry': 6}