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

  Рет қаралды 70,864

London App Developer

London App Developer

Күн бұрын

Пікірлер: 50
@Richard-yz2gy
@Richard-yz2gy Жыл бұрын
nice vid cheers :)
@ragnarhelgi9397
@ragnarhelgi9397 5 жыл бұрын
Epic! Thank you man this helped me a lot, keep up the good work!
@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?
@TheCbrown146
@TheCbrown146 4 жыл бұрын
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?
@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??
@thairston1
@thairston1 3 жыл бұрын
# 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?
@pushpendrakushwaha604
@pushpendrakushwaha604 3 жыл бұрын
I have the same doubt
@udaypamphilos
@udaypamphilos 4 жыл бұрын
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
@registeredrepublican7297
@registeredrepublican7297 3 жыл бұрын
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.
@swallowedinthesea11
@swallowedinthesea11 6 жыл бұрын
Awesome! Thank you from Texas! Stay safe during the Coronavirus.
@PatentPending20
@PatentPending20 4 жыл бұрын
Hey, this video is awesome, and you're a great teacher. Thank you.
@LondonAppDeveloper
@LondonAppDeveloper 4 жыл бұрын
Thank you :)
@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
@harshsahu2767
@harshsahu2767 5 жыл бұрын
Sir plz increase your font size for more convenience 😁😎
@matthieu_fulhaber
@matthieu_fulhaber 2 жыл бұрын
thx for video im learning python at school :)
@Farhan-mv7es
@Farhan-mv7es 4 жыл бұрын
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 жыл бұрын
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".
@LondonAppDeveloper
@LondonAppDeveloper 6 жыл бұрын
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 3 жыл бұрын
What if you wanted to filter by price less than $2.00, for example?
@marlenevergara326
@marlenevergara326 3 жыл бұрын
@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 жыл бұрын
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
@hennieliebenberg7114
@hennieliebenberg7114 6 жыл бұрын
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 жыл бұрын
Advice is always welcome and better late than never :) Thank you for the reply though!!!
@ebrahimabidi4224
@ebrahimabidi4224 3 жыл бұрын
Ty bro! U da GOAT
@sickie1034
@sickie1034 2 жыл бұрын
5 years later - still helpfull
@LondonAppDeveloper
@LondonAppDeveloper 2 жыл бұрын
Great to hear!
@LondonAppDeveloper
@LondonAppDeveloper 4 жыл бұрын
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
@OGBonesPro
@OGBonesPro 5 жыл бұрын
Awesome! Thanks a bunch!
@kalkidanberhe827
@kalkidanberhe827 3 жыл бұрын
Thank you much.
@LondonAppDeveloper
@LondonAppDeveloper 3 жыл бұрын
You're welcome!
@stlo0309
@stlo0309 4 жыл бұрын
Thanks a lot!
@LondonAppDeveloper
@LondonAppDeveloper 4 жыл бұрын
You're welcome. Thank you!
@karlavillarrealleal1254
@karlavillarrealleal1254 4 жыл бұрын
Thank you!
@ares106
@ares106 4 жыл бұрын
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.!.!.!
@emilyncozzens8309
@emilyncozzens8309 2 жыл бұрын
Thank you so much!
PYTHON VIRTUAL ENVIRONMENTS (Beginner's Guide to Python Lesson 9)
6:35
London App Developer
Рет қаралды 75 М.
Advanced Dictionaries: defaultdict in Python
13:12
NeuralNine
Рет қаралды 30 М.
My scorpion was taken away from me 😢
00:55
TyphoonFast 5
Рет қаралды 2,7 МЛН
Python For Loops - Python Tutorial for Absolute Beginners
14:42
Programming with Mosh
Рет қаралды 642 М.
Python - Accessing Nested Dictionary Keys
24:48
Academind
Рет қаралды 188 М.
Python - полный курс для начинающих. Этот навык изменит твою жизнь.
5:27:42
6 Tips to write BETTER For Loops in Python
9:19
Patrick Loeber
Рет қаралды 251 М.
This Is Why Python Data Classes Are Awesome
22:19
ArjanCodes
Рет қаралды 821 М.
Using Python enumerate() With for Loops
14:01
Real Python
Рет қаралды 26 М.
Dictionary in Python
12:24
Telusko
Рет қаралды 1,4 МЛН
Python Full Course for Beginners
6:14:07
Programming with Mosh
Рет қаралды 42 МЛН
My scorpion was taken away from me 😢
00:55
TyphoonFast 5
Рет қаралды 2,7 МЛН