Write a function called remove_duplicates which will take one argument called string. This string input will only have characters between a-z.
The function should remove all repeated characters in the string and return a tuple with two values:
A new string with only unique, sorted characters.
The total number of duplicates dropped.
For example:
remove_duplicates('aaabbbac') => ('abc', 5)
remove_duplicates('a') => ('a', 0)
remove_duplicates('thelexash') => ('aehlstx', 2)
Here's my solution, and I'm new to python:
string = raw_input("Please enter a string...")
def remove_duplicates(string):
string = set(string)
if only_letters(string):
return (string, string.length)
else:
print "Please provide only alphabets"
remove_duplicates(string)
What might I be doing wrongly? This is the error I get below
THERE IS AN ERROR/BUG IN YOUR CODE Results: /bin/sh: 1: python/nose2/bin/nose2: not found
Thanks.