如何解决“类型'int'的TypeError参数不可迭代”。

时间:2019-11-20 20:48:50

标签: python python-2.7

for i in range(8):
    ***if by in X[wining[i][0]] and by in X[wining[i][1]] and by in X[wining[i][2]]:***
        checker = 1
        if who == 'P1':
            conter [0] +=1
        elif who == 'P2' :
            conter[1] +=1 
        if vs_player == "boot":
            print "---------YOU WIN!---------"
        elif vs_player =="P2":
            print "---------%s WINER!---------" % who
            print "%s\n\t---------%s---------" % ("""\n %s | %s | %s\n__|___|___\n %s | %s | %s\n__|___|___\n %s | %s | %s """ 
            % (X[0], X[1], X[2], X[3], X[4], X[5], X[6], X[7], X[8]), print_conter)
        del played[:]
        X = [0, 1, 2, 3, 4, 5, 6, 7, 8]
        break

1 个答案:

答案 0 :(得分:0)

try:
    for i in range(8):
        if by in X[wining[i][0]] and by in X[wining[i][1]] and by in X[wining[i][2]]:
            checker = 1
            if who == 'P1':
                conter [0] +=1
            elif who == 'P2' :
                conter[1] +=1 
            if vs_player == "boot":
                print "---------YOU WIN!---------"
            elif vs_player =="P2":
                print "---------%s WINER!---------" % who
                print "%s\n\t---------%s---------" % ("""\n %s | %s | %s\n__|___|___\n %s | %s | %s\n__|___|___\n %s | %s | %s """ 
                % (X[0], X[1], X[2], X[3], X[4], X[5], X[6], X[7], X[8]), print_conter)
            del played[:]
            X = [0, 1, 2, 3, 4, 5, 6, 7, 8]
            break
excpet:
    typeError