0

Print duplicate elements in the list and how many times they present in the list?..a = [1,2,3,5,8,4,7,9,1,4,12,5,6,5,2,1,0,8,1]

Please help Ans : 1- 4 2-2 5-3 4-2 8-2

3rd Jun 2020, 6:25 AM
Yabesh Sam
Yabesh Sam - avatar
7 Respostas
+ 2
Iterate through the list and make a dictionary of each element and it's count which will ensure that there are no duplicates. This hint is enough to solve the problem.
3rd Jun 2020, 6:28 AM
XXX
XXX - avatar
+ 2
Please Show us your attempt
3rd Jun 2020, 6:32 AM
ANJALI SAHU
+ 1
Thankyou bro 👐
3rd Jun 2020, 7:13 AM
Yabesh Sam
Yabesh Sam - avatar
0
input = [1,2,3,5,8,4,7,9,1,4,12,5,6,5,2,1,0,8,1] Dict = {} for i in range(len(input)): Dict[input[i]] = input.count(input[i]) Print(dict) This is I am trying
3rd Jun 2020, 6:48 AM
Yabesh Sam
Yabesh Sam - avatar
0
You were almost there..missed one step ... HOPE IT HELPS😃 https://code.sololearn.com/cGMRieh5xxiv/?ref=app
3rd Jun 2020, 7:06 AM
ANJALI SAHU