小编pom*_*eii的帖子

为什么我的if语句没有比较列表项

    alphabet =["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"]
def decoder(input):
    inputlist = list(input)
    inputlength = len(input)
    alphabetlength = len(alphabet)
    result = "Decoded Sentence: "
    for x in range(inputlength):
        for y in range(alphabetlength):
            if inputlist[x] is alphabet[y]:
                print ("hi")
                if y == 24:
                    result += "a"
                if y == 25:
                    result += "b"
                else:
                    result += alphabet[y+2]
            if inputlist[x] is "(":
                result += "("
            if inputlist[x] is ")":
                result += ")"
            if inputlist[x] is ".":
                result += "."
            if inputlist[x] is " ":
                result += " " …
Run Code Online (Sandbox Code Playgroud)

python comparison loops nested

0
推荐指数
1
解决办法
1268
查看次数

标签 统计

comparison ×1

loops ×1

nested ×1

python ×1