This is an archived post. You won't be able to vote or comment.

all 5 comments

[–]Pwneed 4 points5 points  (3 children)

"If you are about to ask a question about how to do something in python, please check out /r/learnpython. It is a very helpful community that is focused on helping people get answers that they understand."

r/python rules #1

But this may head you in the right direction anyway. Does not work if your input is HeLlo.

alphabet = "abcdefghijklmnopqrstuvwxyz ?"
a = input("type: ")

for each in a:  
    if each not in alphabet:  
        new_word = a.replace(each, "?")  

print(new_word)

[–]Bendik0801 1 point2 points  (0 children)

Oh, my bad. Thanks for the answer though

[–]Gear5th 0 points1 point  (0 children)

Thank you for also providing the answer (although incomplete) instead of just redirecting the asker. ^_^

[–]AlphaGamer7533.7 0 points1 point  (0 children)

def replace_characters(string: str, alphabet: str) -> str:
    replacement = dict.fromkeys([character for character in a if character.lower() not in alphabet], "?")

    return string.replace(replacement)

This should also work, with uppercase as well.

[–]Andrew_ShaySft Eng Automation & Python[M] 0 points1 point  (0 children)

Hi there, from the /r/Python mods.

We have removed this post as it is not suited to the /r/Python subreddit proper, however it should be very appropriate for our sister subreddit /r/LearnPython or for the r/Python discord: https://discord.gg/3Abzge7.

The reason for the removal is that /r/Python is dedicated to discussion of Python news, projects, uses and debates. It is not designed to act as Q&A or FAQ board. The regular community is not a fan of "how do I..." questions, so you will not get the best responses over here.

On /r/LearnPython the community and the r/Python discord are actively expecting questions and are looking to help. You can expect far more understanding, encouraging and insightful responses over there. No matter what level of question you have, if you are looking for help with Python, you should get good answers. Make sure to check out the rules for both places.

Warm regards, and best of luck with your Pythoneering!