[英]variable to call list value - python
I need my game to run this:我需要我的游戏来运行这个:
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)
but then I get this:但后来我明白了:
if line[x] == line2[x]:
TypeError: 'NoneType' object has no attribute '__getitem__'
and I'm calling with我打电话给
for p in range(2,1025):
first = w_win([" ","2","16"," "],[" ","2"," ","32"],p)
any help?有什么帮助吗?
Your w_win function is missing the return statement which is required when you are assigning the function's value to the variable 'first'.您的 w_win 函数缺少将函数的值分配给变量“first”时所需的 return 语句。 In your case the variable first is initialized to Class of 'NoneType' because of missing return statement.
在您的情况下,由于缺少 return 语句,变量首先被初始化为“NoneType”类。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.