5th Sep 2020, 10:26 PM
Ishan
Ishan - avatar
6 Respostas
+ 2
a=[2,4,8,16,32,64] b=[4,8,12,16,20,24,32,40,64] c=[8,16,24,32,40,64,80] d={} for i in a+b+c: if i in d: d[i]+=1 else: d[i]=1 for i in d: if d[i]==3: print(i) #2nd way d= a +b+c for i in d : if d.count(i) >= 3 : print(i) d.remove(i) Edit: I think, you mean s implication, or other alternatives...
5th Sep 2020, 10:50 PM
Jayakrishna 🇮🇳
+ 2
Ishan .sort_index() The dict was already sorted, I added it to the list. It should sort every time
6th Sep 2020, 12:09 AM
Steven M
Steven M - avatar
+ 1
I would try using Pandas, I believe the output is the same https://code.sololearn.com/ck0G7w9z3PUX/#py
5th Sep 2020, 11:15 PM
Steven M
Steven M - avatar
+ 1
Steven M what can be done to maintain order ? thnx for ur code ..
5th Sep 2020, 11:48 PM
Ishan
Ishan - avatar
+ 1
Desired output can be achieved with list only. pls find the code. a=[2,4,8,16,32,64] b=[4,8,12,16,20,24,32,40,64] c=[8,16,24,32,40,64,80] d=[] for i in a: if (i in b )and (i in c): d.append(i) print(*d,sep="\n") https://code.sololearn.com/cLnN0JEat5es/?ref=app
7th Sep 2020, 1:51 AM
Vikas Jain
Vikas Jain - avatar
0
Jayakrishna🇮🇳 Thank you ....
5th Sep 2020, 10:57 PM
Ishan
Ishan - avatar