Skip to content

Instantly share code, notes, and snippets.

@samatt
Created February 14, 2013 00:12
Show Gist options
  • Save samatt/4949621 to your computer and use it in GitHub Desktop.
Save samatt/4949621 to your computer and use it in GitHub Desktop.
#my first python program
import sys
#searchString = 'a'
#trString = 'e'
def translator(w):
return w.replace(searchString,trString)
searchString = sys.argv[1]
trString = sys.argv [2]
for letter in searchString:
letter = searchString[1]
print letter
for line in sys.stdin:
line = line.strip()
#make a list of words from the line in stdin
words = [w for w in line.split(" ")]
# translate each word in that line
translated = [translator(w) for w in words]
print " ".join(translated)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment