A Clever Way To Use Sets In Python

preview_player
Показать описание
Рекомендации по теме
Комментарии
Автор

Very well done and explained!! It really helps that you went step by step with an expanded solution but then ALSO showed the refactored version which is extremely helpful in understanding both ways overall and how you came to it - Thank you so much for doing that!! 😊👏

_silentrose
Автор

Not sure which is faster, but a list comprehension one-liner would have also worked

murphygreen
Автор

Great video! Could I suggest a following one with an explanation about the memory addresses of each array. You do have another video about variables, but this is a subject that I really struggle at. Thanks for your work!

machado
Автор

very interesting, didnt knew sorted returns list

Your_Friend
Автор

I discovered this channel a few days ago, I enjoy your content and how you explain the topics. I hope you are doing well.

TheKingMo
Автор

Is there any groupby() function in python. When I use it I encountered Name error

themobilegamer
Автор

any idea where i can learn the testing method ?

mzmzeee
Автор

can this code can be also correct :-
def mega_arry(a, b):
c=a+b
s=set(c)
new=list(s)
new.sort()
print("the new list", new)
a1= input("enter the nuber: ")
b2=input("enter the nuber: ")
a=[]
b=[]
for i in range(len(a1)):
i=int(i)
a.append(i)
for j in range(len(b2)):
j=int(j)
b.append(j)
mega_arry(a, b)

red
Автор

in the first way to solve this challenge we don't need sorted function . the list function will sort the items
def merge_arrays(arr1, arr2):
arr3= arr1+arr2
arr4= list(set(arr3))
print(arr4)
return arr4

TheKingMo
Автор

I dropped a like even if I didn't learn anything cause it is super well explained :)

LouisBarjon
Автор

What is the secret of that prompt on ur terminal? Can you share that ?

hamadrehman
Автор

Set automatically sorts itself on init, isnt it?

shadow_blader
Автор

Mind sharing what VS Code theme that is? :)

robertodelgado
Автор

I like it, in the end I would it even like it more if you wrote a lambda 🙂
merge_arrays = lambda arrayA, arrayB: sorted(set(arrayA + arrayB))
a = [3, 3, 3, 1, 1, 1, 2, 2, 2, 3, 3, 3]
b = [4, 5, 6]
print(merge_arrays(a, b))

Sinke_
Автор

Yo Man, great work. Work is your theme?

stampsheep
Автор

camelCase? In your Python? It’s more likely than you think

voyant_
Автор

The hard-coded tests were mildly infuriating💀

k_gold