Created
October 2, 2015 01:28
-
-
Save NotTheEconomist/ae027bd2585ac3422ec0 to your computer and use it in GitHub Desktop.
This file contains 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
$ python -c "import tmp; print(tmp.spaceitout('I love dogs', 2))" | |
I l o v e d o g s | |
$ python -c "import tmp; print(tmp.spaceitout2('I love dogs', 2))" | |
I love dogs | |
$ cat expectedresult.txt | |
I l o v e d o g s |
This file contains 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
I l o v e d o g s |
This file contains 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
def spaceitout(source, count): | |
return (' '*count).join([letter for letter in source.replace(' ','')]) | |
def spaceitout2(source, count): | |
return (' '*count).join(source.split()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment