Epic! Thank you man this helped me a lot, keep up the good work!
@du4222 жыл бұрын
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?
@TheCbrown1464 жыл бұрын
where does the stock_count come in on the 2nd for loop? This is where I am not that great at traversing yet.
@TheCbrown1464 жыл бұрын
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?
@miriam96233 жыл бұрын
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??
@thairston13 жыл бұрын
# 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?
@pushpendrakushwaha6043 жыл бұрын
I have the same doubt
@udaypamphilos4 жыл бұрын
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():
@alexbabich26983 жыл бұрын
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
@registeredrepublican72973 жыл бұрын
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.
@swallowedinthesea116 жыл бұрын
Awesome! Thank you from Texas! Stay safe during the Coronavirus.
@PatentPending204 жыл бұрын
Hey, this video is awesome, and you're a great teacher. Thank you.
@LondonAppDeveloper4 жыл бұрын
Thank you :)
@hseas37934 жыл бұрын
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?
@ramoun164 жыл бұрын
use the enumerate() function: listy = ['apples','oranges'] for index , item in enumerate(listy): print(index, item) # output: # 1 apples # 2 oranges
@harshsahu27675 жыл бұрын
Sir plz increase your font size for more convenience 😁😎
@matthieu_fulhaber2 жыл бұрын
thx for video im learning python at school :)
@Farhan-mv7es4 жыл бұрын
Sir it would be great if u could've explained us how to use for loops in dictionaries with if-elif-else statement.
@LondonAppDeveloper4 жыл бұрын
Appreciate the feedback! I'll keep it in mind when planning future content.
6 жыл бұрын
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".
@LondonAppDeveloper6 жыл бұрын
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']
@marlenevergara3263 жыл бұрын
What if you wanted to filter by price less than $2.00, for example?
@marlenevergara3263 жыл бұрын
@London App Developer
@hasibkhan95375 жыл бұрын
sir please tell me how to use dictionary for make english dictionary if user enter some word it can show the meaning
@Strunoder245 жыл бұрын
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_SteveK5 жыл бұрын
@@Strunoder24 loooooool , human: 'piece of meat_'mom':gay
@hennieliebenberg71146 жыл бұрын
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)
@ramoun164 жыл бұрын
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
@hennieliebenberg71144 жыл бұрын
Advice is always welcome and better late than never :) Thank you for the reply though!!!
@ebrahimabidi42243 жыл бұрын
Ty bro! U da GOAT
@sickie10342 жыл бұрын
5 years later - still helpfull
@LondonAppDeveloper2 жыл бұрын
Great to hear!
@LondonAppDeveloper4 жыл бұрын
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: kzbin.info/www/bejne/bp2viKeoarCtopI
@OGBonesPro5 жыл бұрын
Awesome! Thanks a bunch!
@kalkidanberhe8273 жыл бұрын
Thank you much.
@LondonAppDeveloper3 жыл бұрын
You're welcome!
@stlo03094 жыл бұрын
Thanks a lot!
@LondonAppDeveloper4 жыл бұрын
You're welcome. Thank you!
@karlavillarrealleal12544 жыл бұрын
Thank you!
@ares1064 жыл бұрын
mmm cox
@arctictimberwolf2 жыл бұрын
Fee Fye Foe Fum
@aidankieffer3 жыл бұрын
Why aren’t we using f strings! Hehehe
@naresh.c26775 жыл бұрын
he like apples more
@jessieorozco31863 жыл бұрын
I wouldn't recomend this song. All thumbs down.!.!.!