I have an assignment where I have to decode a string by finding an offset code. The offset code represents the number of positions the character in the string has been moved in the alphabet. If I can find this number, I can supposedly decode the string.
This is the string: vyzhesjdpwqncjae
I was thinking of creating a for-loop to iterate through the string and change each character's position, and see which iteration produces a word. But I'm not quite sure how to do this.
This is the code I have so far:
def decode (newInput):
for i in range (1,27):
newInput2 = newInput[i+1]
print "Trying to decode:", newInput2
decode(newInput)
But this isn't working. I would like the output to print the combination of words possible for each iteration - when each character in the string is moved one space along, two, three...until 26. Is this the best way of doing that?
Keep in mind, I'm quite the beginner, and I think I should stick to for-loops. I have seen some posts on using the dictionary function, but I haven't quite learned that yet.
Thank you for your help!