Sample Input: sssssssssssssssddddeeeeggggggghhhhh
Output: sdegh
1st way:
string_data=input("Enter string: ") result='' for character in string_data: if character not in result: result=result+character print("You entered: ",string_data) print("Final result after removing duplicate characters: \n", result )
2nd way:
string_data=input("Enter string: ") list_data=[] for character in string_data: if character not in list_data: list_data.append(character) result="".join(list_data) print("You entered: ",string_data) print("Final result after removing duplicate characters: \n", result )
No comments:
Post a Comment