所以我正在尝试创建一个函数,要求用户输入文本,结果应该打印文本的加密版本。它应该工作的方式是所有符号都不匹配此变量中的任何符号:alphabet = "abcdefghijklmnopqrstuvwxyz ?"应该用问号代替'?'。例如:'THIS is a t#est'会导致'???? is a t?est'. 这是我到目前为止所得到的。alphabet = "abcdefghijklmnopqrstuvwxyz ?"xalphabet = list(alphabet)code = input('Please enter the text you want to code: ')xcode = list(code)def clean_text(xcode): for xcode in xalphabet: if xcode == xalphabet: continue else: xcode.replace(xcode, '?') return xcodedef main (): print(clean_text(xcode))if __name__ == "__main__": main()我得到的只有印刷品 '?'
添加回答
举报
0/150
提交
取消