我正在制作一个用户输入一些文本的程序,并且我不想将该文本中不在变量“alfabet”中的所有字符更改为“?”。我怎样才能做到这一点?我还想在两个函数中完成它,main 和 clean_text。我的代码现在看起来像这样:
def clean_text():
for char in text:
if char in alfabeth:
continue
elif char not in alfabeth:
#don't know what to do here
#text[] = "?"
def main():
userInput = input("type in text: ")
text = list(userInput)
if__name__ == "__main__":
main()
clean_text(text)
炎炎设计
相关分类