Fill This Form To Receive Instant Help
Homework answers / question archive / How do I output the exact same thing but with a while loop? Code: a = {"A":{"a", "b", "c"} ,"B":{"e", "f", "g"}, "C":{"h", "i,", "j"}} b = {} for aplha in a: b[aplha] = len(a[aplha]) print(aplha) print(b[aplha]) print(b) Output: A 3 {'A': 3} B 3 {'A': 3, 'B': 3} C 3 {'A': 3, 'B': 3, 'C': 3}
How do I output the exact same thing but with a while loop?
Code:
a = {"A":{"a", "b", "c"} ,"B":{"e", "f", "g"}, "C":{"h", "i,", "j"}}
b = {}
for aplha in a:
b[aplha] = len(a[aplha])
print(aplha)
print(b[aplha])
print(b)
Output:
A
3
{'A': 3}
B
3
{'A': 3, 'B': 3}
C
3
{'A': 3, 'B': 3, 'C': 3}