【发布时间】:2016-10-30 15:58:20
【问题描述】:
我已经制作了一种秘密语言,我可以将完整的单词放入输入中并按照列表中的字母得到输出。假设我输入“AB”,我希望输出为“QW”。
while True:
print("type sentence you want translated")
Befor=input()
After=list(Befor)
if Befor=="A":
print("Q")
elif Befor=="B":
print("W")
elif Befor=="C":
print("E")
elif Befor=="D":
print("R")
else:
print("--")
print(After)
pass
【问题讨论】:
-
您能解释一下您在实施过程中遇到的问题吗?发生了什么不符合您的预期?
-
我一次只能用一个字母来做这个,我想让它做完整的单词
-
看来您刚刚开始学习 Python。尝试使用
for letter in Befor:,您可以在其中放置if-elif-else块。
标签: python string python-3.x