Created
April 28, 2020 20:09
-
-
Save roman-on/bb7e5b404876ac33868abb965a9a8ac6 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
The function gets a string and deletes the letters that appear in sequence. That is, | |
the function returns a string containing only one character from each sequence of identical characters in the input string. | |
>>> sequence_del("ppyyyyythhhhhooonnnnn") | |
'python' | |
>>> sequence_del("SSSSsssshhhh") | |
'Ssh' | |
>>> sequence_del("Heeyyy yyouuuu!!!") | |
'Hey you!' | |
""" | |
# function removing extra letters from your sentence | |
def sequence_del(my_str): | |
result = "" # casting the result to string | |
for letter in my_str: # running the letters | |
if not (letter in result) or (letter != result[-1]): # conditions checking if the letter in the sentence or not | |
result += letter # if the condition true you transfer all the letters to here | |
return result | |
def main(): | |
<your code here> | |
if __name__ == "__main__": | |
main() | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment