Answer the question
In order to leave comments, you need to log in
How to find out how many elements and their values are in the dictionary?
The bottom line is this, I have a dictionary called ad_features
which can have any number of elements with their values, the task is this: to pull out all its elements and their value from the dictionary
Please tell me how this can be implemented?
Answer the question
In order to leave comments, you need to log in
If "I have a dictionary" then it is absolutely incomprehensible how you managed to create it without understanding how to work with the dictionary? Just copied the finished code somewhere, or what?
dict = {'А': [173, 70], 'Б': 12345, 'С': 'Привет семье', 'D':{'D1':'Aу','D2':'[1,2,3]','D3':321}}
for itm in dict.items():
print(itm)
('А', [173, 70])
('Б', 12345)
('С', 'Привет семье')
('D', {'D1': 'Aу', 'D2': '[1,2,3]', 'D3': 321})
data = {'a':1, 'b': 2, 'c': 1}
for key in data:
print(f'{key}: {data[key]}')
print(len(data), '\n')
for key in data.keys():
print(f'{key}: {data[key]}')
print(len(data.keys()), '\n')
for key, value in data.items():
print(f'{key}: {value}')
print(len(data.items()))
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question