Here is the problem:
- Replace input string with the following: The first and last characters, separated by the count of distinct characters between the two.
- Any non-alphabetic character in the input string should appear in the output string in its original relative location.
Here is the code I have thus far:
word = input("Please enter a word: ")
first_character = word[0]
last_character = word[-1]
unique_characters = (list(set(word[1:-1])))
unique_count = str(len(unique_characters))
print(first_character[0],unique_count,last_character[0])
For the second part, I have thought about using regex, however I have not been able to wrap my head around regex as it is not something I ever use.