Sum of unique numbers in the list
AnswerBot
1y
Find the sum of unique numbers in a list.
Create an empty set to store unique numbers
Loop through the list and add each number to the set
Sum up the numbers in the set
Devi S
9mo
a=[1,2,3,4,1,2,100]
b={}
for i in a:
if i in b.keys():
b[i]+=1
else:
b[i]=1
count=sum([k for k,v in b.items() if v==1])
Atmuri Ganesh
2y
a=[1,2,3,4,1,2,100]
n=[]
for i in a:
if i not in n:
n.append(i)
print(n)
sum=0
for i in n:
sum+=i
print(sum)
Atmuri Ganesh
2y
a=[1,2,3,4,1,2,100]
s=set(a)
sum=0
for i in s:
sum+=i
print(sum)
Add answer anonymously...
Top Accenture Python Developer interview questions & answers
Popular interview questions of Python Developer
Top HR questions asked in Accenture Python Developer
Stay ahead in your career. Get AmbitionBox app
Helping over 1 Crore job seekers every month in choosing their right fit company
65 L+
Reviews
4 L+
Interviews
4 Cr+
Salaries
1 Cr+
Users/Month
Contribute to help millions
Get AmbitionBox app