GroupBy Function Question | IITM PYTHON OPPE 1 Previous year question (PYQ) by MyCampus

preview_player
Показать описание
Connect with me over Instagram for any sort of queries!

Checkout our Other Playlists

Multivariable Calculus :

==========================================================
ABOUT OUR CHANNEL
Our channel is about Teaching and Exploring. We cover lots of cool stuff such as Data science, Machine learning and Coding
Check out our channel here:
Don’t forget to subscribe!
==========================================================
GET IN TOUCH
==========================================================
FOLLOW US ON SOCIAL
Get updates or reach out to Get updates on our Social Media Profiles!
Рекомендации по теме
Комментарии
Автор

def group_by(L):
groups = {}
for num in L:
if num in groups:
groups[num].append(num)
else:
groups[num] = [num]
return list(groups.values())

L = [1, 2, 1, 5, 4, 5, 4, 3, 4]
print(group_by(L))

JassKaur-
Автор

ans=[]
s=set(l)
for i in s:
n= l.count(i)
temp=[]
for _ in range(n):
temp.append(i)
ans.append(temp)
return ans

SudhanshuShekhar-hhuj
Автор

def groupb_by(n):
l = []
while(len(n)!=0):
i = 0
g = n[i]
m = []
p = n.count(g)
for j in range(p):
m.append(g)
n.remove(g)
l.append(m)
l.sort()
return (l)

print(groupb_by([1, 2, 1, 5, 4, 5, 4, 3, 4]))

Brother ye kaisa hai??❤

DivyanshGupta-efrt
Автор

What is the time duration between oppe 1 and oppe 2

gayathrimahadevoju
Автор

def create_list(L):
S = set(L)
D = {i:[] for i in S}
return D
def group_by(L):
D = create_list(L)
for num in L:
if num in D:
D[num].append(num)
L = []
for key, value in D.items():
L.append(value)
return L

L = [1, 2, 1, 5, 4, 5, 4, 3, 4]
Q = group_by(L)
print(Q)

VASUVERMA-dm
Автор

Bhai for loop mei bhi kar sakte hai right isko??

Ariana_Gandhi