Back

code kata-strings

Created 3 years ago
107 Views
3 Comments
krithikaI73GKS
@krithikaI73GKS
krithikaI73GKS
@krithikaI73GKSProfile is locked. Login

Question: You are given a string ‘s’. Print all the duplicate characters of string.

my code is:

string = input()

elements = {}

for char in string:

if char in elements:

elements[char] += 1

else:

elements[char] = 1

print(-1)

for key, value in elements.items():

if value > 1:

print(key)

print()

i dono how to rectify it.could some help me out

Testcase Status:

>>> error

Input:

abcdd

Expected Output:

d

Actual Output:

-1

d

Comments (3)
Please login to comment.