How to Iterate Through a Dictionary in Python

  Рет қаралды 66,921

Real Python

Real Python

Күн бұрын

Пікірлер: 22
@jesuisravi
@jesuisravi 3 жыл бұрын
I really like how you take pains to make the coding easy to follow, easy to read. So many coding videos don't bother with this crucial aspect of this sort of tutorial. They present you with an unmagnified IDE screen and proceed to waste your time talking you through a process that NEEDS to be seen to be effectively followed.
@Miluud
@Miluud 4 жыл бұрын
I like this video. In just about 6 minutes I learned more than I would've learned by watching a 60 minutes video
@dahuangll
@dahuangll 5 жыл бұрын
Recently, I used dict very often, it is really useful of your video, thank you!
@saartnomsky4523
@saartnomsky4523 2 жыл бұрын
this was actually super useful bro, thanks
@ronaldjohnson4470
@ronaldjohnson4470 4 жыл бұрын
Thank you for the tutorial. I've noticed tutorials on dictionaries always begin with a populated dictionary. How would populate a dictionary automatically with a loop? thanks again.
@patriciomendez644
@patriciomendez644 4 жыл бұрын
Thanks for the clear explanation!
@RamonTomzer
@RamonTomzer Жыл бұрын
very well explained, thank you!
@mini_mouseinthehouse
@mini_mouseinthehouse 4 жыл бұрын
Thank you for the tutorial. Very helpful!
@BethanyLowe8773
@BethanyLowe8773 3 жыл бұрын
Thanks. The thing that's often confusing about such examples is working out whether "key", "values", "item" etc are protected built-in words, or related to something else in the statement, or could be any actually meaningful variable. So I come out still feeling vague.
@dexter-phillips
@dexter-phillips 3 жыл бұрын
Very helpful video thanks!
@_whiteforest7473
@_whiteforest7473 4 жыл бұрын
thanks!!! this video is really helpful!!!!
@scraped_2454
@scraped_2454 3 жыл бұрын
What text editor are you using?
@liomon41
@liomon41 4 жыл бұрын
Hey, firstly love the tutorial but I can't seem to figure out how to display the contents of a nested dictionary... example example = { { 'color' : 'red', 'fruit' : 'apple', 'species' : 'dog' }, { 'color' : 'black', 'fruit' : 'blackberry', 'species' : 'panda' }, { 'color' : 'blue', 'fruit' : 'blueberry', 'species' : 'elephant' }, } My question is : how do you go about iterating over a nested dict(above) just like the example you gave in the video ? Again great tutorial, thanks for your help in advance .
@puzzlesolver9088
@puzzlesolver9088 4 жыл бұрын
Your example is lacking a key for those nested dicts. It should look like this (keys don't have to be ints, but they have to be hashable): example = { 1: { 'color' : 'red', 'fruit' : 'apple', 'species' : 'dog' }, 2: { 'color' : 'black', 'fruit' : 'blackberry', 'species' : 'panda' }, 3: { 'color' : 'blue', 'fruit' : 'blueberry', 'species' : 'elephant' }, } Lets say you want to iterate through each dict and print it's key and value you can use nested for loops like this: for key, value in example.items(): for k, v in value.items(): print(k, v) print('---------') The output will look like this: color red fruit apple species dog --------- color black fruit blackberry species panda --------- color blue fruit blueberry species elephant I hope it helps :)
@CameraMeetsWorld
@CameraMeetsWorld 2 жыл бұрын
@@puzzlesolver9088 Your comment actually helped me more than the video, Thanks!! Video was great but still got confused in some parts
@vladepast4936
@vladepast4936 3 жыл бұрын
WHere is "the next video on dictionary"? I cannot find it. Thank you.
@kassytan7797
@kassytan7797 2 жыл бұрын
same here
@abhinavsingh4208
@abhinavsingh4208 3 жыл бұрын
THANKYOUUU SO VERYY MUCHH ! GOD BLESS YOU BROTHER.
@revenge9431
@revenge9431 4 жыл бұрын
If i have a list with 100 values in them. How do i iterate through them by groups of 5 without repeating any previous iteration Thanks
@gabrielabdul
@gabrielabdul 4 жыл бұрын
The deer function lol
@GeneralBlorp
@GeneralBlorp 5 жыл бұрын
Some folks pronounce dir() as "der", as in how you might pronounce "directory". Pronunciations probably vary by language / person / region / method of learning Python... I just say what the other folks say around me, unless they are dirty "jiff"ers. To hell with THOSE people. Another good one is "toopal" versus "tuppel", as alternate pronunciations of tuple. Anyways thanks for the content my dude.
@user-havedalmolok8
@user-havedalmolok8 Жыл бұрын
Thinks sir
Python dictionaries are easy 📙
8:06
Bro Code
Рет қаралды 281 М.
Ful Video ☝🏻☝🏻☝🏻
1:01
Arkeolog
Рет қаралды 14 МЛН
"Идеальное" преступление
0:39
Кик Брейнс
Рет қаралды 1,4 МЛН
How to have fun with a child 🤣 Food wrap frame! #shorts
0:21
BadaBOOM!
Рет қаралды 17 МЛН
Python dataclasses will save you HOURS, also featuring attrs
8:50
Python - Accessing Nested Dictionary Keys
24:48
Academind
Рет қаралды 188 М.
15 Python Libraries You Should Know About
14:54
ArjanCodes
Рет қаралды 411 М.
Learn Python OOP in under 20 Minutes
18:32
Indently
Рет қаралды 167 М.
25 nooby Python habits you need to ditch
9:12
mCoding
Рет қаралды 1,8 МЛН
*Args and **Kwargs in Python
3:49
b001
Рет қаралды 294 М.
Python dictionary comprehension 🕮
8:41
Bro Code
Рет қаралды 41 М.
Ful Video ☝🏻☝🏻☝🏻
1:01
Arkeolog
Рет қаралды 14 МЛН