I don’t have any code but I am really stuck on how to shift letters based off an input. e.g: the user inputs 1 so A is B and B is C etc.
alphabet = ['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']
direction = input("Type 'encode' to encrypt, type 'decode' to
decrypt:\n")
text = input("Type your message:\n").lower()
shift = int(input("Type the shift number:\n"))
>Solution :
I am providing a basic solution for your problem, modify if to suit your needs.
alphabet = [
"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",
]
text = input("Type your message:\n").lower()
shift = int(input("Type the shift number:\n"))
new_text = ""
for character in text:
new_text += chr(ord(character) + shift)
print(new_text)