Hey guys I've started my very first program ever, lol yay.
Anyways, of course I'm having a problem (never fails).
I am trying to make a program that takes a word, and ceaser encodes it, or shifts it's alphibet place. Hopefully you will understand from the program. I haven't started on the undoing part, as for some reason the code is not responding. I don't get an error message, and it does not print "test" in the shell.
Heres the code
print "test"
letters = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z',1 ,2 , 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]
word = ("hello")
len(word) = var_1
var_2 = 0
d = []
encoded= []
var_4 = 0
while var_2 < (var_1 + 1):
letters.index(word[var_2]) = var_3
var_3 + 5 = x
d.append(x)
var_2 = var_2 + 1
while var_4 < (var_1 + 1):
mid.append(letters[d[var_4]])
var_4 = var_4 + 1
encoded = "".join(mid)
print encoded
Please help understand what is wrong, as I'm very new to the language, and I've only had about five nights to study it so far.
Thanks,
Joe
did you really run your code using the Python interpreter? If you have, you will get errors, i am sure of that. Your LHS and RHS of your assignment is messed up.
len(word) = var_1
should be
var_1 = len(word)
similarly for
letters.index(word[var_2]) = var_3
and
var_3 + 5 = x
Fix them and then run your code again.
PS. there are better ways to do what you are doing.