First, try using a dict() to store the mappings. Lots easier.
mymappings = dict()
def add_mapping( l1, l2):
mymappings[l1] = l2
mymappings[l2] = l1
add_mapping('a','e')
add_mapping('b','z')
...
word = None
while word != '':
word = raw_input("Word:")
print ''.join( [mymappings[x] for x in word if mymappings.has_key(x)] )
Then just do a list comprehension on your string to write out the mapped characters. You are not getting 1 letter at a time, you are getting 1 string at a time. Therefore you need to now write out the string modified.
Also use raw_input, not input for pulling in strings.
3
solved Python Code Creation [closed]