PYTHON DICTIONARIES & FOR LOOPS (Beginner's Guide to Python Lesson 8)

แชร์
ฝัง
  • เผยแพร่เมื่อ 26 ต.ค. 2024

ความคิดเห็น • 50

  • @LondonAppDeveloper
    @LondonAppDeveloper  3 ปีที่แล้ว

    We've just launched: *Python for Beginners: Learn how to code properly in 2021*
    The *FREE* preview covers _all_ the topics found in this playlist and more: th-cam.com/video/8lLWtr5Kzl0/w-d-xo.html

  • @emilyncozzens8309
    @emilyncozzens8309 ปีที่แล้ว +1

    Thank you so much!

  • @Richard-yz2gy
    @Richard-yz2gy ปีที่แล้ว +1

    nice vid cheers :)

  • @ragnarhelgi9397
    @ragnarhelgi9397 5 ปีที่แล้ว +4

    Epic! Thank you man this helped me a lot, keep up the good work!

  • @thairston1
    @thairston1 3 ปีที่แล้ว +1

    # This is the dictionry
    pips = {"Tie":1, "Noah":2, "Ma":3, "rye":4, "Law":5, "shoe":6, "Cow":7, "ivy":8, "Bee":9, "Toe":10}
    # Request the user pick a number to the associated Key
    Peg = input(“ pick a number from 1-10 ” + pips [ ])
    Print(“This is your associated key ” + peg)
    #How do you get the associated user input to the dictionry?

  • @harshsahu2767
    @harshsahu2767 5 ปีที่แล้ว +7

    Sir plz increase your font size for more convenience 😁😎

  • @registeredrepublican7297
    @registeredrepublican7297 2 ปีที่แล้ว

    Underrated viedo...video... think if you went through more ways to do it and larger dicts it would be even better. You do have the best one I've seen out of the many. Regular editor and real loops. Good job. Update it. I would definitely watch.

  • @matthieu_fulhaber
    @matthieu_fulhaber 2 ปีที่แล้ว

    thx for video im learning python at school :)

  • @PatentPending20
    @PatentPending20 3 ปีที่แล้ว +1

    Hey, this video is awesome, and you're a great teacher. Thank you.

  • @swallowedinthesea11
    @swallowedinthesea11 6 ปีที่แล้ว +1

    Awesome! Thank you from Texas!
    Stay safe during the Coronavirus.

  • @Farhan-mv7es
    @Farhan-mv7es 4 ปีที่แล้ว +1

    Sir it would be great if u could've explained us how to use for loops in dictionaries with if-elif-else statement.

    • @LondonAppDeveloper
      @LondonAppDeveloper  4 ปีที่แล้ว +1

      Appreciate the feedback! I'll keep it in mind when planning future content.

  • @sickie1034
    @sickie1034 2 ปีที่แล้ว

    5 years later - still helpfull

  • @ebrahimabidi4224
    @ebrahimabidi4224 3 ปีที่แล้ว

    Ty bro! U da GOAT

  • @du422
    @du422 2 ปีที่แล้ว

    I am trying to update a nested dictionary within for loop. The issue I am facing is the dictionary within dictionary values are a list and I need to update say 100th index of the list with a numpy array element. It updates inside the loop using either exec command or using key value pair in for loop. But outside for loop I see that all the elements are updated with the last numpy element, It looks the for loop is overwriting the list for each dictioanry. Any solution?

  • @OGBonesPro
    @OGBonesPro 5 ปีที่แล้ว

    Awesome! Thanks a bunch!

  • @TheCbrown146
    @TheCbrown146 4 ปีที่แล้ว +1

    where does the stock_count come in on the 2nd for loop? This is where I am not that great at traversing yet.

    • @TheCbrown146
      @TheCbrown146 4 ปีที่แล้ว

      I think I understand what may be possibly: for apple[key] , stock_count[value] in apple.items(): Is this correct? I found some examples stating that d.items(): allows you to not only show the key, but portray the value of the key as well?
      Stock_count is a variable name that we give; wherein, we couldn't named it 'poop' and it would still work, right?

  • @udaypamphilos
    @udaypamphilos 4 ปีที่แล้ว +1

    Can you help me understand how "stock_count" worked in your code. you did not define that as a variable before so i couldn't follow how you used it in the second 'for' loop.
    for apple, stock_count in apples.items():

    • @alexbabich2698
      @alexbabich2698 3 ปีที่แล้ว

      It would have made more sense if he didn't use apple. Could have just wrote k, v for key and value and it works the same

  • @kalkidanberhe827
    @kalkidanberhe827 3 ปีที่แล้ว

    Thank you much.

  • @miriam9623
    @miriam9623 3 ปีที่แล้ว

    But yes, what if i wanted to create a dictionary based on previously made list and use the values from that as keys.. how do i get them into the dictionary then??

  • @karlavillarrealleal1254
    @karlavillarrealleal1254 4 ปีที่แล้ว

    Thank you!

  • @hennieliebenberg7114
    @hennieliebenberg7114 5 ปีที่แล้ว

    Hello im hoping you can help me. I have 2 dictionaries that i need to get the total_value of.
    I need to get "the total_value is 280.36" displayed in the console.
    stock = {
    "Apples": 15,
    "Banana": 20,
    "Cherries": 19,
    "Strawberries": 10,
    }
    print(stock)
    price = {
    "Apples": 4.99,
    "Banana": 2.99,
    "Cherries": 3.99,
    "Strawberries": 6.99,
    }
    print(price)

    • @ramoun16
      @ramoun16 4 ปีที่แล้ว

      too late i know but myabe someone needs that in the future:
      method #1:
      sum = 0
      for key , value in stock.items():
      sum += values
      print(sum) # 64
      method #2:
      sum = 0
      for value in price.values():
      sum += value
      print(sum) # 18.96
      #coding_is_fun

    • @hennieliebenberg7114
      @hennieliebenberg7114 4 ปีที่แล้ว +1

      Advice is always welcome and better late than never :) Thank you for the reply though!!!

  • @hseas3793
    @hseas3793 4 ปีที่แล้ว

    If I had data from an excel sheet I believe I can use openxpy to grab the data and make python work with it. From there how could I make it so that instead of filtering for lets say the number of gala, fiji, pink lady, etc apples--- how could i make it so that python can draw the numbers for them automatically?

    • @ramoun16
      @ramoun16 4 ปีที่แล้ว

      use the enumerate() function:
      listy = ['apples','oranges']
      for index , item in enumerate(listy):
      print(index, item)
      # output:
      # 1 apples
      # 2 oranges

  •  5 ปีที่แล้ว

    Hello, can you help me with this dict?
    asort= [
    {'name': 'apple', 'price': 2.49},
    {'name': 'orange', 'price': 23.90},
    {'name': 'banana', 'price': 3.49},
    ]
    How to create the function that search the fruit and return the price. For example: client write input "apple" and function returns "2.49".

    • @LondonAppDeveloper
      @LondonAppDeveloper  5 ปีที่แล้ว +2

      For this you would need to loop through the array and check if item['name'] == 'apple'... This would be quite inefficient because if you have 1,000 items and the one you need happens to be at index 999, you need to loop through each item to find the right one.
      A more efficient approach would be to have a flat dictionary and use the name as the key... So:
      {'apple': {'price': 2.49}, 'banana': {'price': 3.00}}
      Then you can locate apple using: apple = fruits['apple']

    • @marlenevergara326
      @marlenevergara326 2 ปีที่แล้ว

      What if you wanted to filter by price less than $2.00, for example?

    • @marlenevergara326
      @marlenevergara326 2 ปีที่แล้ว

      @London App Developer

  • @hasibkhan9537
    @hasibkhan9537 5 ปีที่แล้ว

    sir please tell me how to use dictionary for make english dictionary if user enter some word it can show the meaning

    • @Strunoder24
      @Strunoder24 5 ปีที่แล้ว +1

      well I guess you need to use searchable word as a KEY and meaning as VALUE. Something like:
      dictionary = {'apple': 'a fruit', 'human': 'peace of meat', 'mom': 'gay'}

    • @Dr_SteveK
      @Dr_SteveK 5 ปีที่แล้ว

      @@Strunoder24 loooooool , human: 'piece of meat_'mom':gay

  • @ares106
    @ares106 3 ปีที่แล้ว +2

    mmm cox

  • @arctictimberwolf
    @arctictimberwolf 2 ปีที่แล้ว

    Fee Fye Foe Fum

  • @aidankieffer
    @aidankieffer 3 ปีที่แล้ว

    Why aren’t we using f strings! Hehehe

  • @naresh.c2677
    @naresh.c2677 5 ปีที่แล้ว

    he like apples more

  • @jessieorozco3186
    @jessieorozco3186 3 ปีที่แล้ว

    I wouldn't recomend this song. All thumbs down.!.!.!

  • @stlo0309
    @stlo0309 3 ปีที่แล้ว

    Thanks a lot!