Created
January 13, 2011 05:10
-
-
Save I82Much/777436 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 reverse.py I like dogs | |
dogs like I |
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
import sys | |
def reverseSentence(sentence): | |
reversed = sentence.split()[::-1] | |
return " ".join(reversed) | |
def main(): | |
sentence = " ".join(sys.argv[1:]) | |
print reverseSentence(sentence) | |
if __name__ == '__main__': | |
main() | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment