I wish did fix the issue. It's a simple problem, I'm not sure why you're trying to complicate it. Your solution looks good, except for the fact that you should use .join() instead of '+' to join strings together.
Python character check and replacement
By : Colin Chase
Date : March 29 2020, 07:55 AM
this will help You can check if an input character is in alphabet and replace it with '?' if it's not there.
alphabet = 'abcdefghijklmnopqrstuvwxyzæø˚a ?'
text = input('Text input: ')
print(''.join(['?' if x not in alphabet else x for x in text]))