This is my code:
chile_ranks = {'ghost': 1, 'habanero': 2, 'cayenne': 3}
rank_dict = {rank: name for name, rank in chile_ranks.items()}
chile_len_set = {len(name) for name in rank_dict.values()}
print(rank_dict)
print(chile_len_set)
Output:
{1: 'ghost', 2: 'habanero', 3: 'cayenne'}
set([8, 5, 7])
I wanted to print the length of item values respectively as they are arranged in the dictionary, but they are appended to the set in an arbitrary manner. It should be like:
set([5, 8, 7])