I learned how to use default dictionaries! thanks for these videos again super useful! please don't stop making content!
@Лена-в1н6ы Жыл бұрын
This is my first comment in English on utube. I liked your videos, this and others, they are all very interesting and useful. Thank you very much!
@jasonchien53598 ай бұрын
Amazing video regarding the usage of defaultdict, learnt a lot and I see the benefits over the default dictionary compare to defaultdict class. Keep up the good work 👍👍👍
@ВладФоменко-р4е Жыл бұрын
I just recently run into this defaultdict in my colleague's code, and now you share what it's all about. How's that work?)) Thank you for a great tutorial.
@SolidBuildersInc Жыл бұрын
This was a Game Changer on Dictionaries for me. I will read the docs....🎉
@aflous Жыл бұрын
@11:44 you still can have some logic using a callable, no need to inherit from defaultdict
@JoseAntonio-jf5lz Жыл бұрын
Excellent explanation, thank you very much.
@kvelez Жыл бұрын
from collections import defaultdict words = ["apple", "banana", "carrot", "avocado", "brocoli"] grouped_words = {defaultdict(list)} for word in words: grouped_words[word[0]].append(word) print(grouped_words)
@turtlecode8 ай бұрын
Perfect tutorial!
@pawelantczak6476 Жыл бұрын
Is default dict. quicker/better vs standard_dict[new_key]=standard_dict.get(new_key,0)+current_value?
@BenKariuki-s7o9 күн бұрын
Bro doesn't blink
@pranee31 Жыл бұрын
Please make a video on "how to use OrderedDict in defaultdict"." defaultdict(lambda: OrderedDict())" how this works?
@alexanderkaess9505 Жыл бұрын
Very good explanation
@BioLife_Hacks Жыл бұрын
thanks a lot, this vid is really useful👌
@paulthomas1052 Жыл бұрын
Thanks - very interesting tutorial.
@kiorde Жыл бұрын
Very useful, thanks!
@ayoife3482 Жыл бұрын
Is it just me or is the audio volume low? 🤔
@yomajo Жыл бұрын
It is
@lxathu Жыл бұрын
Thanks. Being spoiled by awk and perl, I thought about having this a couple of times
@kvelez Жыл бұрын
from collections import defaultdict my_list = [1,2,3,44,56,6,65] counter = defaultdict(int) values = { 0: "person0", 1: "person1", 2: "person2", 3: "person3", } for item in my_list: counter[item] += 1 print(counter)
@RamiSobhani27 күн бұрын
I did not understand much. Could you make another video that explains this concept better?
@kvelez Жыл бұрын
from collections import defaultdict lambda_dict = defaultdict(lambda: "hello world") print(lambda_dict["hello"])
@blendercharacter5418 Жыл бұрын
this is so usful for me right now! Im glad that I found this I'll use it tommorrow ! thank you!
@kvelez Жыл бұрын
from collections import defaultdict tuple_list = [("A",10),("B",4),("A",5),("C",7),("B",1)] grouped_data = defaultdict(list) for k,v in tuple_list: grouped_data[k].append(v) print(grouped_data) grouped_data = {k:sum(v) for k, v in grouped_data.items()} print(grouped_data)
@harsharya828 Жыл бұрын
Please Make Video on Complex Data Type in python.
@sebbyteh9203 Жыл бұрын
although defaultdict is less general compared to the regular dict, I think it's more useful and more powerful than the regular one. it's a shame how underused this function is.
@kvelez Жыл бұрын
from collections import defaultdict class DefaultDicts(defaultdict): def __missing__(self, key): self[key] = value = len(key) return value test = DefaultDicts() print(test["hello"]) print(test["hi"]) print(test)