簡體   English   中英

調用列表值的變量 - python

[英]variable to call list value - python

我需要我的游戲來運行這個:

def w_win(l,l2,check):
    line = l
    line2 = l2
    for x in range(4):
        if line[x] == line2[x]:
            if len(str(check+check)) == 1:
                line[x] = "  "+str(check+check)+" "
            if len(str(check+check)) == 2:
                line[x] = "  "+str(check+check)+""
            if len(str(check+check)) == 3:
                line[x] = " "+str(check+check)
            if len(str(check+check)) == 4:
                line[x] = str(check+check) 

但后來我明白了:

if line[x] == line2[x]:

TypeError: 'NoneType' object has no attribute '__getitem__'

我打電話給

for p in range(2,1025):

    first = w_win([" ","2","16"," "],[" ","2"," ","32"],p)

有什么幫助嗎?

您的 w_win 函數缺少將函數的值分配給變量“first”時所需的 return 語句。 在您的情況下,由於缺少 return 語句,變量首先被初始化為“NoneType”類。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM