所以我正在嘗試創(chuàng)建一個函數(shù),要求用戶輸入文本,結(jié)果應(yīng)該打印文本的加密版本。它應(yīng)該工作的方式是所有符號都不匹配此變量中的任何符號:alphabet = "abcdefghijklmnopqrstuvwxyz ?"應(yīng)該用問號代替'?'。例如:'THIS is a t#est'會導(dǎo)致'???? 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
提交
取消