Could I solve It with re? https://code.sololearn.com/ciVha3KUphUX/?ref=app
you need to handle all non alphabetic chars rather than only spaces: for char in string: if not char.isalpha(): encoded_string += char else: encoded_string += dict_encoder[char]
shorter way would be to use dict.get() method with default value: for char in string: encoded_string += dict_encoder .get(char,char) then if char is not a key of dict, it will return the unchanged char ;)
You can make your dict_encoder like this instead and replace everything between alphabet = [......] dict_encoder = dict(zip(alphabet, alphabet[::-1])) string = input()
Simple and efficient code👇👇✌️ : import string inp = (input()).lower() alps = string.ascii_lowercase l1 =  for i in alps: l1.append(i) # print(l1, inp) count =  for i in inp: try: count.append(l1.index(i)) except ValueError: count.append(" ") # print(count) str = '' for i in count: try: str += l1[25-i] except TypeError: str += " " print(str)
Free month of PRO subscription
Please help me with HTML
Unable to overload +
Please tell me, I used a linear gradient on the blocks, pixels appeared, how can I fix it? Why did this happen?
What is the mistake here?
Struggling to learn
Pls rectify the errors.