Caesar Cipher-Python,嵌套循环

时间:2014-10-18 21:50:06

标签: python python-2.7 rot13

word = ((raw_input("please enter the letters  ")).upper())
word = word.replace(" ","")
word.decode('utf-8', 'ignore')
wordlist = list(word.strip())
numberlist = []
newlist = []
num = 0

while num <= 13:
    for i in wordlist:    #conversion from letters to numbers
        numberlist.append(ord(i))

    for i in numberlist:    #bigger than Z check
        numberlist[numberlist.index(i)] = i + num+1
        if i >= 90:
            numberlist[numberlist.index(i)] = (i - 90) + 65

    for i in numberlist :
        newlist.append(chr(i))

    print ''.join(newlist)
    num += 1
    del newlist[:]
    del numberlist[:]

我在'for i in list:'循环

中分支循环时出现问题

1 个答案:

答案 0 :(得分:0)

我发现有两件事是错的。

未定义'list'变量。

'我在列表中:'如果它不在您的程序中,则不会运行。