file_name = raw_input('Name of the file you will use to encode the your data \n')
file_name = file_name+'.txt'
fp = open(file_name, 'r')
text = fp.read()
#create a string that is just the first letter of every word in the sentence then close file
output = ""
for i in text.split():
output += i[0]
fp.close()
#Enter the information to be encoded
coordinates = raw_input('Write out the coordinates in word form and press <Enter>\n\n')
#convert string to lower case and shorten it to just 99 cariters
coordinates = coordinates .replace(' ', '')
lower_case = output.lower()
short_str = lower_case[0:99]
# initialize counter and cipher
count = 0
cipher = 0
#run through data and substitute index number of key file text for corresponding letter
#if next substitution cannot be found reset search to begining of coordinates string
for letter in coordinates:
if short_str.find(letter, cipher, len(coordinates)) < 0:
cipher = 0
else:
cipher += 1
if cipher > 100:
cipher = 0
if count % 10 == 0:
print
#print encoded string in blocks of ten digits each
cipher = short_str.find(letter, cipher)
print cipher + 1,
count += 1
The program works however, whenever, it comes accross a letter it can't find a substatution for in the text file it pints 0, and I'd like to have it print X or just and underscore. How can I do this?