Python Tutorial for Beginners 5: Dictionaries - Working with Key-Value Pairs

  Рет қаралды 1,482,128

Corey Schafer

Corey Schafer

7 жыл бұрын

In this Python Beginner Tutorial, we will begin learning about dictionaries. Dictionaries allow us to work with key-value pairs in Python. We will go over dictionary methods, how to add and remove values, and also how to loop through the key-value pairs. Let's get started.
The code from this video can be found at:
github.com/CoreyMSchafer/code...
Watch the full Python Beginner Series here:
• Python Programming Beg...
✅ Support My Channel Through Patreon:
/ coreyms
✅ Become a Channel Member:
/ @coreyms
✅ One-Time Contribution Through PayPal:
goo.gl/649HFY
✅ Cryptocurrency Donations:
Bitcoin Wallet - 3MPH8oY2EAgbLVy7RBMinwcBntggi7qeG3
Ethereum Wallet - 0x151649418616068fB46C3598083817101d3bCD33
Litecoin Wallet - MPvEBY5fxGkmPQgocfJbxP6EmTo5UUXMot
✅ Corey's Public Amazon Wishlist
a.co/inIyro1
✅ Equipment I Use and Books I Recommend:
www.amazon.com/shop/coreyschafer
▶️ You Can Find Me On:
My Website - coreyms.com/
My Second Channel - / coreymschafer
Facebook - / coreymschafer
Twitter - / coreymschafer
Instagram - / coreymschafer
#Python

Пікірлер: 839
@1cannon3
@1cannon3 5 жыл бұрын
0:07 - Terminology 0:14 - Key/Value pairs definition 0:37 - First example (Student using a dictionary) 0:45 - { }, Dict notation, curly braces, 0:50 - adding elements 1:32 - [ ] Square bracket access of the dict 2:04 - Dict items can be many things, they’re not bound to one “type” 2:14 - Keys can be any immutable data type 2:24 - Example of an Integer being the key 2:44 - Accessing a key that does not exist 3:00 - Alternative to “throwing an error” if a key does not exist 3:05 - Sometimes you will want to return None or a default value if key does not exist 3:09 - .get( ) access of the dict 3:30 - accessing a key that does not exist with the .get method as opposed to [ ] square bracket access 3:40 - Specifying a default value for keys that do not exist 4:01 - Adding a new entry to dictionary 4:30 - Changing/updating values via key access 5:02 - Changing/updating values via .update() method 5:21 - .update() takes in a dict as an argument 5:57 - Deleting a specific key and its value 6:01 - Option 1 for deleting a key and value: del keyword 6:26 - Option 2 for removing a key and value: .pop() method 6:30 - Remember the .pop() method not only removes the item put pops it off or returns it to you 6:35 - Therefore you can recover the popped item with a variable assignment 7:07 - How to loop through all the keys and values 7:13 - Finding out the number of keys in dict with len() function 7:30 - Print all keys with .keys() method 7:39 - Print all values with .values() method 7:47 - Print both keys and values with .items() method 8:07 - Looping is slightly different then lists because dicts are concerned with pairs (Key : Value) 8:33 - How to loop through keys AND values
@dreamscapeai7
@dreamscapeai7 4 жыл бұрын
Nice, this helps, thanks
@yesdone4993
@yesdone4993 4 жыл бұрын
thank u
@MrXIndependent
@MrXIndependent 4 жыл бұрын
God among men.
@andyn6053
@andyn6053 4 жыл бұрын
How do you write a list with all the content with links like this?
@MrXIndependent
@MrXIndependent 4 жыл бұрын
@@andyn6053 diligent note taking. and you make the links by typing the time like 1:02
@k8ysk8
@k8ysk8 3 жыл бұрын
You are absolutely a lifesaver! My compsci prof is really smart, but absolutely terrible at explaining things efficiently. I understand more about dictionaries now after your 10-minute video than I previously did after my 3-hour lecture. Thank you so much, I will definitely be subscribing and donating to your patreon in the future! (once covid is over and I have a job again ):)
@majormac7814
@majormac7814 2 жыл бұрын
most compsci profs ive noticed r too smart to teach newcomers
@master-oh6zn
@master-oh6zn Жыл бұрын
did you donate him
@m.night_shyamamalama_sama_kun
@m.night_shyamamalama_sama_kun Жыл бұрын
Fulfill thy promise and donate, my child.. or face the wrath of our comments
@soundrex9995
@soundrex9995 Жыл бұрын
Yea seems like a lot of teachers r like that I’ve noticed a lot of these ppl who know compsci say they were self taught so it’s not like a regular class that would have traditional methods of teaching
@umxltiii9796
@umxltiii9796 8 ай бұрын
@@majormac7814 I would call it arrogance lol
@alecwilliams945
@alecwilliams945 6 жыл бұрын
These tutorials are some of the best that I have seen out and cover a wide assortment of topics from Beginner to Advanced. Great Work Man!
@MyTube4Utoo
@MyTube4Utoo 6 жыл бұрын
Best Python tutorials on the planet!
@vinaynair1911
@vinaynair1911 6 жыл бұрын
true
@KalvinPatel
@KalvinPatel 6 жыл бұрын
how well do you know python now? I'm about to watch the next video after this dictionary one. Gonna continue on but just wondering has it benefited you yet?
@savitaprabhakar3010
@savitaprabhakar3010 4 жыл бұрын
@@vinaynair1911 yeaaaaaa'
@Ninja-iq2xt
@Ninja-iq2xt 7 жыл бұрын
Glad to see you with totally refreshed Python Tutorials, Thank you so much Corey!
@goncalosd
@goncalosd 4 жыл бұрын
What a Legend! Someone going out of his way just to make knowledge available to others... that is Special. Congratulations Corey, these videos are awesome !
@brijeshsamal7035
@brijeshsamal7035 3 жыл бұрын
I love Corey's videos, they're super simple and straight to the point, and explain everything very well.
@sfs25c
@sfs25c 6 жыл бұрын
I was struggling to learn Python.Even I took a course to learn Python.But I will Thumbs UP to you for explaining all the topic in such a easy.Your videos are the best.With each video, I am gaining confidence.
@coreyms
@coreyms 6 жыл бұрын
Thanks! Glad you're learning and finding these helpful!
@Vintagetube310
@Vintagetube310 2 жыл бұрын
You literally explained lists and dictionaries in the simplest terms possible. Thank you so much, I don’t know why professors cannot be like this. You literally gave me more of a clear understanding with the logic and the syntax behind creating dictionary lists with keys and values, as opposed to how my professor does it. Thanks so much. I subscribed. Looking forward to more tutorials.
@raymondtan9112
@raymondtan9112 5 жыл бұрын
Corey has the best Python tutorial in my 3 years of trying about everything
@satyampriyadarshi6314
@satyampriyadarshi6314 4 жыл бұрын
I'm applying for Masters in Data Science and I just want to say that by following your videos, I will be able to develop a strong base and maybe would be able to fulfil my dreams in a long run all the contribution goes to you Mr Corey Schafer I'm thankful to God that I found your channel.
@christ4ever809
@christ4ever809 2 ай бұрын
Hello can you help me out? I am also pursuing MS in Data Science. Give me some valuable advice.
@r3ylow
@r3ylow Ай бұрын
@@christ4ever809 bro prolly died its been 4 years
@christ4ever809
@christ4ever809 Ай бұрын
@@r3ylow lol haha your funny man
@r3ylow
@r3ylow Ай бұрын
@@christ4ever809 oNLY IF IWERE A MAN 💔💔💔💔 LMAO
@christ4ever809
@christ4ever809 Ай бұрын
@@r3ylow uh oh. sorry babes :)
@androidynamit
@androidynamit 3 жыл бұрын
This is hands down the most detailed tutorial series I ever had, Thank You, Corey!!
@effuseakay
@effuseakay 5 жыл бұрын
WOW! that was clear, straight to the point, and perfectly explained!!! Thank you so much!
@yadneshkhode3091
@yadneshkhode3091 5 жыл бұрын
BEST TUTORIAL EVER!!!!!!!!!!!!! glad I found it recommending it to all my friends in college
@AmDsus2Fmaj7Am
@AmDsus2Fmaj7Am 7 жыл бұрын
Just wanted to say you are awesome. Thanks for the videos.
@novicetech1
@novicetech1 6 жыл бұрын
Thanks again. I actually thought I knew python dictionaries. Now I feel like Jon Snow. I know nothing. I could have saved a bunch on Udemy if I had found you first.
@MegaJohn144
@MegaJohn144 5 жыл бұрын
I could say exactly the same thing.
@andyn6053
@andyn6053 4 жыл бұрын
@@MegaJohn144 Udemy is crap
@bpkoiralaproductions6004
@bpkoiralaproductions6004 4 жыл бұрын
@@andyn6053 Yes, Udemy sucks. It would be better and cheaper to just buy a book and read it!
@Ryan-fl2dz
@Ryan-fl2dz 3 жыл бұрын
i'm glad i didnt use udemy so fast...
@JY0002
@JY0002 Жыл бұрын
JON SNOW LOL
@xxPingPangPow
@xxPingPangPow 4 жыл бұрын
I already took a graduate course for intro level Python-- and your videos are honestly better! chugging through the beginner videos as a refresher and I cannot wait to jump into the more advanced topics. I feel so lucky for finding such a great resource-- and it was easy, your videos are so widely reccomended! Thank you for developing such an great and accessible course.
@blackharshdevil4316
@blackharshdevil4316 2 жыл бұрын
hello
@mahshidpooladvand8502
@mahshidpooladvand8502 5 ай бұрын
Mr. Schafer, I've never felt so close to learning these concepts after spending so many Python courses... I will be donating for sure.
@Daverhan02
@Daverhan02 5 жыл бұрын
These videos are very well designed! Thank you for your efforts of creating informative python videos!
@swaantjuh
@swaantjuh 4 жыл бұрын
This is the second time I looked up something about Python on youtube. This was so well explained that I wanted to sub, but apparantly you were also the guy who explained regexes like perfectly, therefore I already subbed.. Thanks for keeping programming fun!
@pax61
@pax61 6 жыл бұрын
The best, most clear and concise description I've found. Good job!
@engr.mubasharhanif
@engr.mubasharhanif 2 ай бұрын
hey, are you programmer or python expert now?
@anshikapal6992
@anshikapal6992 4 жыл бұрын
Man u should be python teacher a great teacher who can explain everything so easily after watching u r video i m having no doubts i m in 11th commerce 😅
@valeriatapia1128
@valeriatapia1128 2 жыл бұрын
Finally someone who explains this stuff in a much simpler and less confusing way. Thank you so much!
@engr.mubasharhanif
@engr.mubasharhanif 2 ай бұрын
hey, are you programmer or python expert now?
@Pythonist
@Pythonist 4 жыл бұрын
Here's an advanced tutorial for python dictionaries if you want to learn more: kzbin.info/www/bejne/n36qY2yLpaiFkLM
@AnkitSharma-um4ml
@AnkitSharma-um4ml Жыл бұрын
The 9 minutes of this tutorial is far better than the 1 hour tutorial I learned from Udemy . Thanks, Corey
@preciousbanigo
@preciousbanigo Ай бұрын
No jokes
@akmzahidulislam2764
@akmzahidulislam2764 3 жыл бұрын
Shot and quick; yet covering all the important aspects of the topic. Many thanks.
@potsatamas4859
@potsatamas4859 6 жыл бұрын
This courses are really helpful! Saves a LOT of time and money! Thank you very much!
@msrikavya9651
@msrikavya9651 6 жыл бұрын
Pótsa Tamás in fact these videos are for learning but if need a certificate that u have a completed a course on python by writing the exams then u can't rely on them:)
@yadneshkhode3091
@yadneshkhode3091 5 жыл бұрын
no one cares for certificates knowledge is everything
@Danieldrd
@Danieldrd 5 жыл бұрын
I've been really enjoying and learning a lot from these videos. Thank you very much for doing this, it's really appreciated!
@mudhitkumar
@mudhitkumar 4 жыл бұрын
Finally, I a feeling confident about programming, I have been trying from so many months just to learn the concepts I have given so many attempts before this as well. Just to memorize the concepts all the time. However, back in the time I found that stuff really difficult to remember. Now with these videos, I can learn how to code and it is really easy to memorize the concepts as well, the way you explain things, it is really awesome, I really appreciate your work. Thank you, Mudhit Kumar
@inc0nsistentgent893
@inc0nsistentgent893 9 ай бұрын
dude...this just explained so much to me in such little time. I have been scratching my head for a while over things and not really understanding some looping within these dictionaries, but your explanation makes so much more sense that its actually starting to come together. Thank you.
@expat2010
@expat2010 3 жыл бұрын
Consistently the best and most efficient videos on every subject you cover!
@gdorman619
@gdorman619 5 жыл бұрын
You're a really good teacher. You make things so easy. Thank you for your videos.
@ataghabouli6254
@ataghabouli6254 Жыл бұрын
These were the tricky ones. I'm a python learner and I was stuck in one of my practice problems. Thanks for this great video Corey!
@raison991
@raison991 Жыл бұрын
Of all the Python videos tutorials you are the best. Very practical and clean concept and usage and fun in learning.
@spencerobrien3213
@spencerobrien3213 5 жыл бұрын
Great Video to help me get a grasp on how dictionaries work! keep up the great work, you are a great instructor!!!
@Aditya-ss1rq
@Aditya-ss1rq 5 жыл бұрын
I dnt how this video ended on my recommended list but its great. Your tutorials are far better than paid tutorials. Subcribed to your channel., 👍
@artur2.043
@artur2.043 Жыл бұрын
Quick concise information. CLEAN. Thank you sir! Best I have found on youtube so far.
@theaoh5237
@theaoh5237 4 жыл бұрын
Sweet and simple breakdown. Very helpful. Thank Corey!
@andyn6053
@andyn6053 4 жыл бұрын
You have the best python tutorials on youtube without any doubt Corey!
@shivrajsingh5559
@shivrajsingh5559 3 жыл бұрын
These are the best article i have found. I completed python from other sources and someone referred me your pandas tutorial they are just awesome. After watching your pandas tutorial wants to again go through all these python tutorial.
@meltedcheese1908
@meltedcheese1908 6 жыл бұрын
I am glad that I found your channel. It is really going to be helpful, thanks mate!
@etc3redsox
@etc3redsox 11 ай бұрын
Hey Corey, I know these videos are geared towards beginners like myself - and also a few years old at this point - but it would be helpful to explain how each concept in the tutorials are used in the real world, beyond just printing out values. Hopefully this makes sense! Thank you for the instruction - I appreciate your teaching style
@Nikhils_Gaming
@Nikhils_Gaming 5 ай бұрын
He kinda does that... The code he used *could* be used in a program that calculates a student's grades or keeps track of them like google classroom. However, it was simplified for the video. Hope this helps
@islamalmsarrhad2152
@islamalmsarrhad2152 8 ай бұрын
I've been learning Python for a while, and you are gifted. Many thanks
@poroshatyazdanbakhshghahya9091
@poroshatyazdanbakhshghahya9091 3 жыл бұрын
Thank you for the brief and concise dictionary tutorial. Looking forward to seeing more tutorials from you.
@arthurivex2298
@arthurivex2298 3 жыл бұрын
I am taking a class at my local College, and your videos are a great supplement to the topics in the class!!! Thank you!
@shivarammuthukumaraswamy7164
@shivarammuthukumaraswamy7164 3 жыл бұрын
This is exactly what i was looking for. The best explanation ever.
@emmanuelmasemola1014
@emmanuelmasemola1014 Жыл бұрын
These are the kind of channels that I subscribe to, very insightful
@swatisrivastav5620
@swatisrivastav5620 3 жыл бұрын
You are amazing, went through other platform courses, even paid ones, but your's is simply amazing. Thank you for existing 🙏. The way you explain every detail that too without letting us feel pressurized is so rare.🥺 Thanks a lot sir 🙏🙏
@vasudev16180
@vasudev16180 3 жыл бұрын
Yes, He is. Thank You for praising my Guru! #KeepLearning
@ahmednazih5686
@ahmednazih5686 5 жыл бұрын
Okay You Sir are a legend! Thank you very much for these Tutorials. hands down best Python Tutorials on Internet
@tanuj05
@tanuj05 7 ай бұрын
Awesome video ! U r a natural teacher ! Loved it
@sanjayursal5330
@sanjayursal5330 3 жыл бұрын
You have the gift of making it easy and interesting to learn. Thanks
@mrmuranga
@mrmuranga 6 жыл бұрын
very simple and nicely put....am a python enthusiast and everyone I learn something from your videos
@kimpierce7825
@kimpierce7825 2 жыл бұрын
You are saving all of my bacon. I didn't know anything about dictionaries before entering into grad school that assumed I was very familiar with them. This is everything. Thank you~~~
@wenyiwang7306
@wenyiwang7306 5 жыл бұрын
I found this is sooooooo easy to understand.!!!The best tutorial for a beginner!
@Astrikification
@Astrikification 6 жыл бұрын
Thanks! It's the best tutorial series on python
@glydon-w2w522
@glydon-w2w522 6 жыл бұрын
I have made a notebook to write down the notes and key points . I dont have to suffer in my college learning basics . I can move forward to advance topics So grateful to you and your indepth Explanation
@marlowemichaelson1366
@marlowemichaelson1366 3 жыл бұрын
Between you and Mosh, I don't know of a better way to learn Python. Thank you so much.
@Child0ne
@Child0ne 2 жыл бұрын
i love your content i am definitely going to be hitting up your patron to support your hard work
@dhoomketu731
@dhoomketu731 6 жыл бұрын
Corey, you are a brother from another mother. You make stuff really easy to understand.
@nachiketwattamwar9706
@nachiketwattamwar9706 5 жыл бұрын
Best python tutorials I ever found....
@sudhapaila8162
@sudhapaila8162 4 жыл бұрын
8
@yusufbabatundeahmed
@yusufbabatundeahmed Жыл бұрын
Thanks Corey. Your explanation is flawless!!
@Nothingspecial604
@Nothingspecial604 2 ай бұрын
Definite like and subscribe here. Extremely well thought out and direct assistance through example. Thanks man you saved me a million migraines
@laurayuan7035
@laurayuan7035 6 жыл бұрын
Thank you! Your video makes my study much easier!
@Faceglitch
@Faceglitch 2 жыл бұрын
The most solid python tutorial I have ever seen. Thank you!
@andyn6053
@andyn6053 5 жыл бұрын
Really great videos! You are way better than my university teacher in explaining things!
@eduardopasseto2387
@eduardopasseto2387 5 жыл бұрын
Many thanks! A great hug from Brazil!
@maheshvenkat9956
@maheshvenkat9956 4 жыл бұрын
This was a comprehensive and well explained video
@sheikhspeare7262
@sheikhspeare7262 4 жыл бұрын
Just from the start of the video I knew you sounded professional. I paused and cake to the comment section and saw a lot of these people learnt. I have just started to actually learn this all. Don’t know any of the languages. If I find this helpful I could probably donate.
@rogsonl
@rogsonl 4 жыл бұрын
Clear and concise, thanks
@rheagalsim7497
@rheagalsim7497 4 жыл бұрын
I've struggled to understand syntax but you've been very clear and explained the 'why' of what to type and functions to call perfectly. Thank you so much! I feel like i'm truly learning and getting it!
@coreyms
@coreyms 4 жыл бұрын
Glad to hear that!
@jameskiarie6923
@jameskiarie6923 3 жыл бұрын
I stumbled upon this and I cannot thank you enough for such clear and awesome tutorials. Merry Xmas.
@abdurahmanomoruyi7753
@abdurahmanomoruyi7753 7 жыл бұрын
I love you corey. you really make my experience with python so much better
@zigirsbiz910
@zigirsbiz910 Жыл бұрын
very clear and simple guide Thank you!
@user-wn3eq6tq7o
@user-wn3eq6tq7o Жыл бұрын
Your videos are so amazing! Thank you for the effort you have put into these :D
@sareng2005
@sareng2005 4 жыл бұрын
wow, thank you. This video was very straight forward and easier than reading a book.
@gauravgoyal6505
@gauravgoyal6505 2 жыл бұрын
i never saw this such great work on youtube related to programming thank man
@user-wj7he9ff6k
@user-wj7he9ff6k 4 ай бұрын
Thanks you Corey! Brilliant tutorials!
@muhammadbinzafar2216
@muhammadbinzafar2216 5 жыл бұрын
Yes, the tutorials here are vastly better - really better.
@judesma2180
@judesma2180 4 жыл бұрын
Your videos are so easy to understand
@soumyazyx
@soumyazyx 4 жыл бұрын
Thank you Corey for your time and effort. Keep spreading the knowledge.
@us-xf3kk
@us-xf3kk 3 жыл бұрын
he will but you donate
@rogal_dorn5600
@rogal_dorn5600 4 ай бұрын
Short and straight to the point. Nice vid m8
@driesdeketele9749
@driesdeketele9749 5 жыл бұрын
Thank you man!! This will save my whole exam!!
@sundarpandey3147
@sundarpandey3147 5 жыл бұрын
Thanks for your time for creating such valuable tutorial.
@ayoolafakoya9841
@ayoolafakoya9841 3 жыл бұрын
really easy to understand with your teaching. thnx a lot
@aguynamedjoe148
@aguynamedjoe148 2 жыл бұрын
Im taking notes and this has helped alot, Thank you so much!!!
@palindrome8845
@palindrome8845 4 жыл бұрын
Very good tutorial. Thanks to you, I now understand dictionaries better.
@LymariArzola
@LymariArzola 2 жыл бұрын
I have been enjoying your videos. Thank you!
@davidbolduc4378
@davidbolduc4378 2 жыл бұрын
This video was the best 10 mins I have had in a while.
@Roboticdock
@Roboticdock 5 жыл бұрын
Thanks Corey for your great video...very educational!
@SadisticKillerXx
@SadisticKillerXx 3 жыл бұрын
Thank you for these tutorials! You really are the best teacher I've found
@poppyseed9967
@poppyseed9967 Жыл бұрын
Very useful video and right to the point! This helped me complete my assignment, thank you!
@aronquemarr7434
@aronquemarr7434 5 жыл бұрын
This is so much better than Programming Knowledge.
@kahsHD215
@kahsHD215 5 жыл бұрын
This was great. So easy to understand!
@shannondsilva3257
@shannondsilva3257 2 жыл бұрын
Spot on explaination. Thank you for this.
@ninakoch1799
@ninakoch1799 3 жыл бұрын
another great video, corey you're a lifesaver!!!
@bumblee_beee
@bumblee_beee Жыл бұрын
One of the clearest explaination.🎉
@franciscorivas4036
@franciscorivas4036 4 жыл бұрын
Your videos are superb! Thank you from Ecuador.
@Syncenator
@Syncenator 2 жыл бұрын
Such a great video and explains it all much better than my teacher tries to in some complicated and confusing ways.
@us-xf3kk
@us-xf3kk 4 жыл бұрын
Best tutorial on KZbin and in the world
@fantakettle100
@fantakettle100 Жыл бұрын
I swear to god this is the only video on youtube that actually properly explains dictionaries without overcomplicating.
Python Tutorial for Beginners 4: Lists, Tuples, and Sets
29:05
Corey Schafer
Рет қаралды 1,4 МЛН
Would you like a delicious big mooncake? #shorts#Mooncake #China #Chinesefood
00:30
ТАМАЕВ vs ВЕНГАЛБИ. Самая Быстрая BMW M5 vs CLS 63
1:15:39
Асхаб Тамаев
Рет қаралды 3,8 МЛН
ПООСТЕРЕГИСЬ🙊🙊🙊
00:39
Chapitosiki
Рет қаралды 66 МЛН
Increíble final 😱
00:37
Juan De Dios Pantoja 2
Рет қаралды 63 МЛН
Python dictionaries are easy 📙
8:06
Bro Code
Рет қаралды 195 М.
5 Good Python Habits
17:35
Indently
Рет қаралды 367 М.
Python - Accessing Nested Dictionary Keys
24:48
Academind
Рет қаралды 179 М.
Dictionary in Python
12:24
Telusko
Рет қаралды 1,3 МЛН
Python Tutorial for Beginners 8: Functions
21:48
Corey Schafer
Рет қаралды 1,1 МЛН
Python Tutorial: Using Try/Except Blocks for Error Handling
10:34
Corey Schafer
Рет қаралды 682 М.
Dictionary Comprehension - Create Complex Data Structures Step by Step
21:58
Python 101: Learn the 5 Must-Know Concepts
20:00
Tech With Tim
Рет қаралды 1 МЛН
Would you like a delicious big mooncake? #shorts#Mooncake #China #Chinesefood
00:30