Python 如何运行循环直到得到每个字母
我正在编写我的凯撒密码程序,当我试图加密我的消息时遇到了一个问题。错误为“函数不可编辑”。所以基本上我想运行for循环,直到它遍历字符串中的所有字母Python 如何运行循环直到得到每个字母,python,loops,Python,Loops,我正在编写我的凯撒密码程序,当我试图加密我的消息时遇到了一个问题。错误为“函数不可编辑”。所以基本上我想运行for循环,直到它遍历字符串中的所有字母 def message(): message = input("Enter your message here: ").upper() return message def key(): while True: key = int(input("Enter your shift or key betw
def message():
message = input("Enter your message here: ").upper()
return message
def key():
while True:
key = int(input("Enter your shift or key between the numbers of 1-26: "))
if key >=1 and key<=26:
return key
def encrypt(message, key):
output = []
for symb in message:
numbers = ord(symb) + 90 - key
output.append(numbers)
print(output)
def消息():
message=input(“在此处输入您的消息:”).upper()
回信
def key():
尽管如此:
key=int(输入(“在1-26之间输入移位或键:”)
如果键>=1且键不重用名称。将加密
的消息
和密钥
参数重命名为其他参数
def encrypt(m, k):
...
def main():
encrypt(message(), key())
不要重复使用名字。将加密
的消息
和密钥
参数重命名为其他参数
def encrypt(m, k):
...
def main():
encrypt(message(), key())
您有与函数同名的变量,这会在运行时导致冲突
弄清楚谁是谁
def message():
msg = input("Enter your message here: ").upper()
return msg
def key():
while True:
k = int(input("Enter your shift or key between the numbers of 1-26: "))
if k >=1 and k <=26:
return k
def消息():
msg=input(“在此处输入消息:”).upper()
返回消息
def key():
尽管如此:
k=int(输入(“在数字1-26之间输入shift或key:”)
如果k>=1且k则变量与函数同名,这会在函数运行时导致冲突
弄清楚谁是谁
def message():
msg = input("Enter your message here: ").upper()
return msg
def key():
while True:
k = int(input("Enter your shift or key between the numbers of 1-26: "))
if k >=1 and k <=26:
return k
def消息():
msg=input(“在此处输入消息:”).upper()
返回消息
def key():
尽管如此:
k=int(输入(“在数字1-26之间输入shift或key:”)
如果k>=1和k,您必须调用您的函数。很抱歉,我不太明白。请您详细说明。变量和函数都称为消息
,这导致了这一冲突。您感谢Python中使用的提示key>=1和key您必须调用您的函数。很抱歉,我不太明白。请详细说明。变量和函数都被称为message
,这导致了这一冲突。您感谢Python中使用的提示key>=1和key