Skip to content

Instantly share code, notes, and snippets.

@uttamg911
Created March 3, 2014 03:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save uttamg911/9317783 to your computer and use it in GitHub Desktop.
Save uttamg911/9317783 to your computer and use it in GitHub Desktop.
# This is a comment in Python
import sys #imports system files
for line in sys.stdin:
line = line.strip() # Strips a string of its trailing white spaces # Tabs tell python that it is part of the loop
word = line.split(' ') # Makes a list of substrings by using space as as delimiter
s = ' '.join(word[::-1]) # [::-1] reverses the contents of a list # The syntax for join is counter intuitive, first you write the delimiter and then the list.
print s # Prints the string
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment