python字符串变量中加个字母_在python中如何使字符串的每个字母都成为变量

我正在尝试用python编写一个编码器

代码在这里。它工作得很好,但我想把字符串中的每个字母改成相应的数字,例如:a=1,b=2。所以最后会变成一个数词。我的目标是有两个程序,一个用于编码,一个用于解码print "Welcome to the encoder"

Letter1 = raw_input ("Please input the first letter of the word: ")

Letter2 = raw_input ("Please input the second letter of the word: ")

Letter3 = raw_input ("Please input the third letter of the word: ")

Letter4 = raw_input ("Please input the fourth letter of the word: ")

Letter5 = raw_input ("Please input the fifth letter of the word: ")

Letter6 = raw_input ("Please input the sixth letter of the word: ")

Letter7 = raw_input ("Please input the seventh letter of the word: ")

Letter8 = raw_input ("Please input the eighth letter of the word: ")

Letter9 = raw_input ("Please input the ninth letter of the word: ")

Letter10 = raw_input ("Please input the tenth letter of the word: ")

Letter11 = raw_input ("Please input the eleventh letter of the word: ")

Letter12 = raw_input ("Please input the twelvth letter of the word: ")

print "Your code is " + Letter3 + Letter2 + Letter1 + Letter6 + Letter5

+ Letter4 + Letter9 + Letter8 + Letter7 + Letter12 + Letter11 +

Letter10

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值