# Ryan Martin
# macid: abcd123
# student number: #######
# July 12, 2011
#
# This is a solution for Marked Assignment 2 (Lab 05) on Wednesday.

def main():

    print """\

This program is a solution to Marked Assignment 2 (Lab 05) on Wednesday.

"""

    #INPUTS
    
    FName = raw_input("Enter the name of the input file containing words: ")
    F = open(FName, "r")
    wordList = F.read().split()
    F.close()
    print 

    #PROCESSING
    print wordList
    reversedList = [] #Or: reversedList = list()
    for word in wordList: 
        reversedWord = list(word) #Splits word into a list
        reversedWord.reverse()
        reversedWord = "".join(reversedWord) #Or: string.join(reversedWord, "")
        reversedList.append(reversedWord)


    '''Alternative method (one of many):
    
    listSize = len(wordList)
    reverseList = range(listSize) #Gets a list of the same size as wordList
    for i in range(listSize):
        reversedWord = list(wordList[i]) 
        reversedWord.reverse()
        reversedList[i] = "".join(reversedWord)
    
    '''

    #OUTPUT
    
    print "The reversed list of words =", reversedList
    print ""

main()

'''
Design Question

There are a few ways to reverse a string in Python:

1. Split the string into a list, use the list's reverse() 
method, then recompile the list into a string:

someList = list(someString)
someList.reverse()
someString = ''.join(someList)

2. Iterate through the string using a loop, and 
construct a new string in reverse order:

newString = ''
for char in someString:
	newString = char + newString

3. A shorthand of method 2, use slice notation for
a string to get the reverse of that string:

newString = someString[::-1]

Testing Report

REPORT

Test: 1
File Content: W
*******************W*******************
apple
pear
mango
orange
pineapple
lime
lemon

Expected Output: ['elppa', 'raep', 'ognam', 'egnaro', 'elppaenip', 'emil', 'nomel']
Actual Output: ['elppa', 'raep', 'ognam', 'egnaro', 'elppaenip', 'emil', 'nomel']
Result:Pass

'''