You are given a list of integers. Find the sum of the unique numbers in the list.

AnswerBot
2y
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
1y
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...
Accenture Python Developer interview questions & answers
A Python Developer was asked 7mo agoQ. Define a lambda function and provide an example.
A Python Developer was asked 7mo agoQ. What are the differences between a list and a tuple?
A Python Developer was asked 7mo agoQ. What is a namespace and what are its types?
Popular interview questions of Python Developer
A Python Developer was asked 7mo agoQ1. Define a lambda function and provide an example.
A Python Developer was asked 7mo agoQ2. What are the differences between a list and a tuple?
A Python Developer was asked 7mo agoQ3. What is a namespace and what are its types?
Stay ahead in your career. Get AmbitionBox app


Trusted by over 1.5 Crore job seekers to find their right fit company
80 L+
Reviews
10L+
Interviews
4 Cr+
Salaries
1.5 Cr+
Users
Contribute to help millions
AmbitionBox Awards
Get AmbitionBox app

