Back

how to print duplicate characters in a string

Created 2 years ago
90 Views
4 Comments
KARAMTHOD
@KARAMTHOD
KARAMTHOD
@KARAMTHODProfile is locked. Login

if i have duplicate i need to print duplicate characters else i need to print "-1"

sample input( )--->abcddee

sample output( ) ---> d e

s=input()

d=[]

for i in s:

if s.count(i)>1:

if i not in d:

d.append(i)

print(*d)

MY DOUBT HERE IS HOW I NEED ADD ELSE STATESMENT IN ABOVE SOLUTION

Comments (4)
Please login to comment.