I'm new to Python and just playing around with some code. I am trying to build a "secret message generator" which takes a string (e.g. "1234567890") and outputs it based on a simple pattern (e.g. "1357924680"). I have the encoder working 90% (currently it can't handle apostrophes), but the decoder is giving me a lot of trouble. For anything over 6 characters, there is no problem. Inputting "1357924680" outputs "1234567890". However, for shorter odd numbered strings (e.g. "Hello"), it does not show the last character (e.g. it outputs "Hell"). My code is below. There may be a simpler way to write it, but since I built this myself, I'd appreciate working with my code rather than rewriting It. So, how can it be fixed?
#simple decoder
def decode(s2):
oddlist = []
evenlist = []
final = []
s2 = s2.lower() #makes a string lowercase
size = len(s2) #gets the string size
print "Size " + str(size) #test print
half = size / 2
print "Half " + str(half)
i = 0
while i < half:
if size % 2 == 0: #checks if it is even
split = size / 2 #splits it
oddlist.append(s2[0:split]) #makes a list of the first half
evenlist.append(s2[split:]) #makes a list of the second half
joinodd = ''.join(oddlist) #list -> string
joineven = ''.join(evenlist) #list -> string
else:
split = (size / 2) + 1
print split
oddlist.append(s2[0:split]) #makes a list of the first half
evenlist.append(s2[split:]) #makes a list of the second half
joinodd = ''.join(oddlist) #list -> string
joineven = ''.join(evenlist) #list -> string
string = joinodd[i] + joineven[i]
final.append(string)
i = i + 1
decoded = ''.join(final)
print final
return decoded
print decode("hello")