wheel = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
wlen = len(wheel) - 1
c = input("Type a word: ").upper()
key = int(input("Key: "))
encrypted = ''
for x in c:
f = wheel.find(x) + key
if x == " ":
encrypted = encrypted + " "
if f > wlen:
f1 = f - wlen - 1
encrypted = encrypted + wheel[f1]
if f < wlen:
encrypted = encrypted + wheel[f]
print(encrypted)
This code isn't working and I can't find a reason why. I need help.
For example "I suck at coding" gives "M DWYGO DEX DGSHMRK"
There is this extra D in all the words that come after space. "M DWYGO DEX DGSHMRK"
Thank You.