I would like to print the item of dictionary. how to do that?
this is my code
{'naruto': [900, 170], 'onepiece': [600, 60]}
for key, value in stock_dict1.items():
for value in stock_dict1.values():
print(key, value[0], value[1])
when I print out, the result will be like this:
how to do that?
naruto 900 170
onepiece 600 60
>Solution :
Using str.ljust and iterable unpacking:
data = {'naruto': [900, 170], 'onepiece': [600, 60]}
for movie, nums in data.items():
print(movie.ljust(12, ' '), *nums)
naruto 900 170
onepiece 600 60