0

I tried to make a program that accepts a list of elements and prints the sum of distinct elements from the list.What has gone wr

https://code.sololearn.com/cgeTTkyiwzxW/?ref=app

3rd Jan 2020, 5:18 PM
SOUMYADEEP BISWAS
4 odpowiedzi
+ 4
I can't try the code, but if you want to just remove duplicates, use this: j = list(set(j)) print(sum(j))
3rd Jan 2020, 5:28 PM
Aymane Boukrouh
Aymane Boukrouh - avatar
+ 2
SOUMYADEEP BISWAS don't try your code on sololearn, try it on a laptop, and see if it works or not
3rd Jan 2020, 5:46 PM
Aymane Boukrouh
Aymane Boukrouh - avatar
0
Yes but here the problem is i am getting one error output and one successful code compilation for two different types of input
3rd Jan 2020, 5:32 PM
SOUMYADEEP BISWAS
0
Aymane Boukrough i tried it on laptop but the results are same The problem is that the code doesn't entirely fail to run. Take two test cases:(number of elements in both cases is set to 5) 1)elements: 4,1,4,3,2 2)elements: 6,9,7,6,8 In first case program runs as it should but in 2nd case it ends with a errorlist index out of range
3rd Jan 2020, 5:51 PM
SOUMYADEEP BISWAS