0
can anyone tell me whats wrong with this code.
import sys import collections n = int(input().strip()) c = map(int,input().strip().split('')) my_s =[] for i in list(set(c)): my_s.append(c.count(i)) total =0 for i in my_s: if i>1: i = i/2 total +=i print (total)
1 Resposta
+ 3
import sys and import collections isn't needed, variable n isn't used. You can't use an empty sequence ('') for string.split(). c is a map object and doesn't have a method count(). for i in list(set(c)) isn't necessary, you can iterate over a set as well. You probably want to print total only once, so it shouldn't be indented