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

Sdílet
Vložit
  • čas přidán 16. 05. 2017
  • 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

Komentáře • 841

  • @1cannon3
    @1cannon3 Před 5 lety +804

    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 Před 4 lety +8

      Nice, this helps, thanks

    • @yesdone4993
      @yesdone4993 Před 4 lety +4

      thank u

    • @MrXIndependent
      @MrXIndependent Před 4 lety +10

      God among men.

    • @andyn6053
      @andyn6053 Před 4 lety

      How do you write a list with all the content with links like this?

    • @MrXIndependent
      @MrXIndependent Před 4 lety +5

      @@andyn6053 diligent note taking. and you make the links by typing the time like 1:02

  • @k8ysk8
    @k8ysk8 Před 4 lety +240

    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 Před 2 lety +12

      most compsci profs ive noticed r too smart to teach newcomers

    • @master-oh6zn
      @master-oh6zn Před rokem +6

      did you donate him

    • @m.night_shyamamalama_sama_kun
      @m.night_shyamamalama_sama_kun Před rokem +6

      Fulfill thy promise and donate, my child.. or face the wrath of our comments

    • @soundrex9995
      @soundrex9995 Před rokem +2

      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 Před 9 měsíci +1

      @@majormac7814 I would call it arrogance lol

  • @alecwilliams945
    @alecwilliams945 Před 6 lety +23

    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!

  • @satyampriyadarshi6314
    @satyampriyadarshi6314 Před 4 lety +57

    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 Před 3 měsíci

      Hello can you help me out? I am also pursuing MS in Data Science. Give me some valuable advice.

    • @r3ylow
      @r3ylow Před 2 měsíci

      @@christ4ever809 bro prolly died its been 4 years

    • @christ4ever809
      @christ4ever809 Před 2 měsíci

      @@r3ylow lol haha your funny man

    • @r3ylow
      @r3ylow Před 2 měsíci

      @@christ4ever809 oNLY IF IWERE A MAN 💔💔💔💔 LMAO

    • @christ4ever809
      @christ4ever809 Před 2 měsíci +2

      @@r3ylow uh oh. sorry babes :)

  • @goncalosd
    @goncalosd Před 4 lety +6

    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 !

  • @Ninja-iq2xt
    @Ninja-iq2xt Před 7 lety +17

    Glad to see you with totally refreshed Python Tutorials, Thank you so much Corey!

  • @novicetech1
    @novicetech1 Před 6 lety +258

    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 Před 5 lety +6

      I could say exactly the same thing.

    • @andyn6053
      @andyn6053 Před 4 lety +3

      @@MegaJohn144 Udemy is crap

    • @bpkoiralaproductions6004
      @bpkoiralaproductions6004 Před 4 lety +10

      @@andyn6053 Yes, Udemy sucks. It would be better and cheaper to just buy a book and read it!

    • @Ryan-fl2dz
      @Ryan-fl2dz Před 3 lety +3

      i'm glad i didnt use udemy so fast...

    • @JY0002
      @JY0002 Před rokem

      JON SNOW LOL

  • @sfs25c
    @sfs25c Před 6 lety +58

    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  Před 6 lety +7

      Thanks! Glad you're learning and finding these helpful!

  • @brijeshsamal7035
    @brijeshsamal7035 Před 3 lety +6

    I love Corey's videos, they're super simple and straight to the point, and explain everything very well.

  • @raymondtan9112
    @raymondtan9112 Před 5 lety +17

    Corey has the best Python tutorial in my 3 years of trying about everything

  • @Vintagetube310
    @Vintagetube310 Před 2 lety +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.

  • @swaantjuh
    @swaantjuh Před 4 lety +8

    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!

  • @AmDsus2Fmaj7Am
    @AmDsus2Fmaj7Am Před 7 lety +97

    Just wanted to say you are awesome. Thanks for the videos.

  • @yadneshkhode3091
    @yadneshkhode3091 Před 5 lety +25

    BEST TUTORIAL EVER!!!!!!!!!!!!! glad I found it recommending it to all my friends in college

  • @MyTube4Utoo
    @MyTube4Utoo Před 6 lety +155

    Best Python tutorials on the planet!

    • @vinaynair1911
      @vinaynair1911 Před 6 lety +1

      true

    • @KalvinPatel
      @KalvinPatel Před 6 lety +1

      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 Před 5 lety

      @@vinaynair1911 yeaaaaaa'

  • @androidynamit
    @androidynamit Před 3 lety +1

    This is hands down the most detailed tutorial series I ever had, Thank You, Corey!!

  • @xxPingPangPow
    @xxPingPangPow Před 4 lety +8

    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.

  • @effuseakay
    @effuseakay Před 5 lety +14

    WOW! that was clear, straight to the point, and perfectly explained!!! Thank you so much!

  • @mudhitkumar
    @mudhitkumar Před 4 lety +5

    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

  • @valeriatapia1128
    @valeriatapia1128 Před 2 lety +4

    Finally someone who explains this stuff in a much simpler and less confusing way. Thank you so much!

  • @inc0nsistentgent893
    @inc0nsistentgent893 Před 10 měsíci

    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.

  • @pax61
    @pax61 Před 6 lety +6

    The best, most clear and concise description I've found. Good job!

  • @Levinsane
    @Levinsane Před rokem +3

    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!

  • @Aditya-ss1rq
    @Aditya-ss1rq Před 6 lety +11

    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., 👍

  • @Daverhan02
    @Daverhan02 Před 5 lety +6

    These videos are very well designed! Thank you for your efforts of creating informative python videos!

  • @mahshidpooladvand8502
    @mahshidpooladvand8502 Před 5 měsíci +2

    Mr. Schafer, I've never felt so close to learning these concepts after spending so many Python courses... I will be donating for sure.

  • @shivrajsingh5559
    @shivrajsingh5559 Před 4 lety +2

    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.

  • @swatisrivastav5620
    @swatisrivastav5620 Před 3 lety +6

    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 Před 3 lety

      Yes, He is. Thank You for praising my Guru! #KeepLearning

  • @akmzahidulislam2764
    @akmzahidulislam2764 Před 3 lety +1

    Shot and quick; yet covering all the important aspects of the topic.
    Many thanks.

  • @anshikapal6992
    @anshikapal6992 Před 4 lety +11

    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 😅

  • @arthurivex2298
    @arthurivex2298 Před 3 lety

    I am taking a class at my local College, and your videos are a great supplement to the topics in the class!!! Thank you!

  • @expat2010
    @expat2010 Před 3 lety

    Consistently the best and most efficient videos on every subject you cover!

  • @potsatamas4859
    @potsatamas4859 Před 6 lety +13

    This courses are really helpful! Saves a LOT of time and money! Thank you very much!

    • @msrikavya9651
      @msrikavya9651 Před 6 lety

      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 Před 5 lety +3

      no one cares for certificates knowledge is everything

  • @Danieldrd
    @Danieldrd Před 6 lety +1

    I've been really enjoying and learning a lot from these videos. Thank you very much for doing this, it's really appreciated!

  • @raison991
    @raison991 Před rokem

    Of all the Python videos tutorials you are the best. Very practical and clean concept and usage and fun in learning.

  • @andyn6053
    @andyn6053 Před 4 lety +1

    You have the best python tutorials on youtube without any doubt Corey!

  • @gdorman619
    @gdorman619 Před 5 lety +1

    You're a really good teacher. You make things so easy. Thank you for your videos.

  • @meltedcheese1908
    @meltedcheese1908 Před 6 lety +2

    I am glad that I found your channel. It is really going to be helpful, thanks mate!

  • @spencerobrien3213
    @spencerobrien3213 Před 5 lety +3

    Great Video to help me get a grasp on how dictionaries work! keep up the great work, you are a great instructor!!!

  • @AnkitSharma-um4ml
    @AnkitSharma-um4ml Před rokem +7

    The 9 minutes of this tutorial is far better than the 1 hour tutorial I learned from Udemy . Thanks, Corey

  • @rheagalsim7497
    @rheagalsim7497 Před 4 lety +1

    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!

  • @poroshatyazdanbakhshghahya9091

    Thank you for the brief and concise dictionary tutorial.
    Looking forward to seeing more tutorials from you.

  • @islamalmsarrhad2152
    @islamalmsarrhad2152 Před 8 měsíci

    I've been learning Python for a while, and you are gifted. Many thanks

  • @artur2.043
    @artur2.043 Před rokem

    Quick concise information. CLEAN. Thank you sir! Best I have found on youtube so far.

  • @kimpierce7825
    @kimpierce7825 Před 2 lety +1

    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~~~

  • @mrmuranga
    @mrmuranga Před 6 lety +2

    very simple and nicely put....am a python enthusiast and everyone I learn something from your videos

  • @glydon-w2w522
    @glydon-w2w522 Před 6 lety +5

    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

  • @etc3redsox
    @etc3redsox Před rokem +14

    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 Před 6 měsíci

      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

  • @theaoh5237
    @theaoh5237 Před 4 lety +1

    Sweet and simple breakdown. Very helpful. Thank Corey!

  • @ahmednazih5686
    @ahmednazih5686 Před 5 lety +4

    Okay You Sir are a legend! Thank you very much for these Tutorials. hands down best Python Tutorials on Internet

  • @marlowemichaelson1366
    @marlowemichaelson1366 Před 3 lety

    Between you and Mosh, I don't know of a better way to learn Python. Thank you so much.

  • @shivarammuthukumaraswamy7164

    This is exactly what i was looking for. The best explanation ever.

  • @patrickimoh
    @patrickimoh Před 3 lety

    Having studied the Python Institute PCAP course, I'm finding this very helpful and I am experiencing some topics that weren't touched, which are useful for data analysis. Stuffs like union, intersection and difference... I'll definitely be watching till the end and will watch all videos again... Thanks for this...

  • @andyn6053
    @andyn6053 Před 5 lety +2

    Really great videos! You are way better than my university teacher in explaining things!

  • @dhoomketu731
    @dhoomketu731 Před 6 lety

    Corey, you are a brother from another mother. You make stuff really easy to understand.

  • @jameskiarie6923
    @jameskiarie6923 Před 3 lety

    I stumbled upon this and I cannot thank you enough for such clear and awesome tutorials. Merry Xmas.

  • @Faceglitch
    @Faceglitch Před 2 lety

    The most solid python tutorial I have ever seen. Thank you!

  • @wenyiwang7306
    @wenyiwang7306 Před 5 lety +1

    I found this is sooooooo easy to understand.!!!The best tutorial for a beginner!

  • @Child0ne
    @Child0ne Před 2 lety

    i love your content i am definitely going to be hitting up your patron to support your hard work

  • @sareng2005
    @sareng2005 Před 4 lety +1

    wow, thank you. This video was very straight forward and easier than reading a book.

  • @sanjayursal5330
    @sanjayursal5330 Před 3 lety +1

    You have the gift of making it easy and interesting to learn. Thanks

  • @suryanshpandey832
    @suryanshpandey832 Před 6 lety +1

    thank you sir, your videos are of great help for people who can't afford expensive courses on various sites.
    so please keep making such good videos
    best of luck from INDIA

  • @abdurahmanomoruyi7753
    @abdurahmanomoruyi7753 Před 7 lety +1

    I love you corey. you really make my experience with python so much better

  • @nachiketwattamwar9706
    @nachiketwattamwar9706 Před 5 lety +8

    Best python tutorials I ever found....

  • @emmanuelmasemola1014
    @emmanuelmasemola1014 Před rokem

    These are the kind of channels that I subscribe to, very insightful

  • @soumyazyx
    @soumyazyx Před 4 lety +2

    Thank you Corey for your time and effort. Keep spreading the knowledge.

    • @us-xf3kk
      @us-xf3kk Před 3 lety

      he will but you donate

  • @232-techs
    @232-techs Před rokem

    This is one of the best ever to encounter video explanation. The content is clearly explained and much easy to understand. Thanks bro...

  • @Nothingspecial604
    @Nothingspecial604 Před 3 měsíci

    Definite like and subscribe here. Extremely well thought out and direct assistance through example. Thanks man you saved me a million migraines

  • @yusufbabatundeahmed
    @yusufbabatundeahmed Před rokem

    Thanks Corey. Your explanation is flawless!!

  • @user-wn3eq6tq7o
    @user-wn3eq6tq7o Před rokem +1

    Your videos are so amazing! Thank you for the effort you have put into these :D

  • @Astrikification
    @Astrikification Před 6 lety +2

    Thanks! It's the best tutorial series on python

  • @fantakettle100
    @fantakettle100 Před rokem

    I swear to god this is the only video on youtube that actually properly explains dictionaries without overcomplicating.

  • @palindrome8845
    @palindrome8845 Před 4 lety +1

    Very good tutorial. Thanks to you, I now understand dictionaries better.

  • @sujaa1000
    @sujaa1000 Před 3 lety +1

    Thanks a bunch to you Corey, I tried to learn Python from a number of resources, but I am able to understand and continue only your explanation. Your selfless service means a lot to a whole lot of people.
    I am learning Python to do some competitive programming, if possible can you make some videos which would need some logical thinking and apply algorithms in Python, which could set the path to take up competitive programming.

  • @gauravgoyal6505
    @gauravgoyal6505 Před 2 lety

    i never saw this such great work on youtube related to programming
    thank man

  • @TonyChen910
    @TonyChen910 Před 7 lety +2

    The tutorial you provided is pretty awesome, which is greater than most of the MOOC course, I am looking forward to the python re module tutorial. BTW, your English accent is awesome toooooo, which makes a lot of things that easy understood for the people that come from other language. Thanks

  • @Syncenator
    @Syncenator Před 2 lety

    Such a great video and explains it all much better than my teacher tries to in some complicated and confusing ways.

  • @muhammadbinzafar2216
    @muhammadbinzafar2216 Před 5 lety +1

    Yes, the tutorials here are vastly better - really better.

  • @kmwong3808
    @kmwong3808 Před 2 lety

    Wow! I didn't fall asleep while watching the video. It is precise and easy to understand.

  • @rogal_dorn5600
    @rogal_dorn5600 Před 5 měsíci +1

    Short and straight to the point. Nice vid m8

  • @aronquemarr7434
    @aronquemarr7434 Před 5 lety +1

    This is so much better than Programming Knowledge.

  • @tanuj05
    @tanuj05 Před 7 měsíci

    Awesome video ! U r a natural teacher ! Loved it

  • @poppyseed9967
    @poppyseed9967 Před rokem

    Very useful video and right to the point! This helped me complete my assignment, thank you!

  • @eduardopasseto2387
    @eduardopasseto2387 Před 5 lety +1

    Many thanks! A great hug from Brazil!

  • @davidbolduc4378
    @davidbolduc4378 Před 2 lety

    This video was the best 10 mins I have had in a while.

  • @sheikhspeare7262
    @sheikhspeare7262 Před 4 lety +1

    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.

  • @maheshvenkat9956
    @maheshvenkat9956 Před 4 lety +2

    This was a comprehensive and well explained video

  • @laurayuan7035
    @laurayuan7035 Před 6 lety +1

    Thank you! Your video makes my study much easier!

  • @SadisticKillerXx
    @SadisticKillerXx Před 3 lety

    Thank you for these tutorials! You really are the best teacher I've found

  • @alexanthony5642
    @alexanthony5642 Před 4 lety +1

    Very good video that gave a well rounded overview and intro to dictionaries. I'm compsci senior and somehow dictionaries got past me. This was a good breakdown. Thank you!

  • @gauravstud
    @gauravstud Před 5 lety

    Hey Corey!
    I love the way you cover the concepts in your video tutorials! Many thanks!
    Could you please cover the topic of OrderedDict and UserDict and Collections module in general.
    That would be very helpful

  • @driesdeketele9749
    @driesdeketele9749 Před 5 lety +1

    Thank you man!! This will save my whole exam!!

  • @Roboticdock
    @Roboticdock Před 5 lety +1

    Thanks Corey for your great video...very educational!

  • @Nia-sk8qo
    @Nia-sk8qo Před 2 lety

    I really do feel comfortable with dictionaries now! Thanks a lot.

  • @MauriceWilliams
    @MauriceWilliams Před 4 lety

    Thank you Corey you are a great teacher I learned a lot from watching this tutorial.

  • @tathagatsharma5773
    @tathagatsharma5773 Před 4 lety +1

    best explanations eveeeeerrrr.... Thanks a lot man your tutorials are way better than anyone else's

  • @ericfarias7159
    @ericfarias7159 Před 6 lety

    Its easy feel comfortable with the dictionary with this video. Thanks a lot!

  • @ErikSkoglund-je7ph
    @ErikSkoglund-je7ph Před rokem

    Currently doing the Python crash course by Coursera and this is just sooooo much better. Amazingly happy I found these videos. Extremely well explained.

    • @benjaminjohnpabroquez8012
      @benjaminjohnpabroquez8012 Před rokem

      You can copy my code and test it for more practice hehe :) that's for free hehe
      foods = {
      "pizza": 20,
      "burger": 40,
      "hotdog": 30,
      "pasta": 25,
      "salad": 15,
      "steak": 50
      }
      order = []
      total = 0
      print("Menu:")
      for food, price in foods.items():
      print(f"{food}: ${price:.2f}")
      while True:
      food = input("Enter the food you'd like to order or q to quit: ").lower()
      if food == "q":
      break
      elif food not in foods:
      print("Invalid food item!")
      else:
      order.append((food, foods[food]))
      total += foods[food]
      print(f"{food} added to order. Total cost so far: ${total:.2f}")
      print("Order summary:")
      for item in order:
      print(f"{item[0]}: ${item[1]:.2f}")
      print(f"Total cost is: ${total:.2f}")

  • @cesar163005
    @cesar163005 Před 5 lety +1

    You master the content and the teaching. Excellent videos. I was learning LPTHW but it is very confusing and in some instance frustrating. If I can, I will be donating something!

  • @AdityaLakshmipathy
    @AdityaLakshmipathy Před 3 lety

    Excellent tutorials. Thank you Corey. Much appreciated.