Sep-23-2019, 03:42 PM
(This post was last modified: Sep-23-2019, 03:42 PM by hoangthai10788.)
Hello,
I encountered this issue when self-learning Python. Could anyone give me a full explanation what is happening here? Any help would be greatly appreciated. Thank you!
I encountered this issue when self-learning Python. Could anyone give me a full explanation what is happening here? Any help would be greatly appreciated. Thank you!
def shift(char, key): alphabet = "abcdefghijklmnopqrstuvwxyz" updated_alphabet = "" if int(key) > 0: for i in range(len(alphabet)): updated_alphabet += alphabet[(int(key) + i) % 26] char_index = alphabet.index(char.lower()) new_char = updated_alphabet[char_index] return new_char def main(): message = "Please help me with this." new_mess = "" for char in message: new_mess += shift(char, 1) return new_mess main()