【发布时间】:2017-01-25 07:49:16
【问题描述】:
我正在做这个 python 编程并且遇到了一个问题。 当我把它放在条件语句中时,程序无法调用n_zero的值。
这是程序
import numpy as np
n_zero=int(input('Insert the amount of 0: '))
n_one =int(input('Insert the amount of 1: '))
n_two =int(input('Insert the amount of 2: '))
n_three = int(input('Insert the amount of 3: '))
data = [0]*n_zero + [1]*n_one + [2]*n_two + [3]*n_three
print len(data)
if len(data)==(2(n_zero)-1):
np.random.shuffle(data)
datastring = ''.join(map(str, data))
print ("Data string is : %s " % datastring )
else:
print(error)
这是错误
if len(data)==(2(n_zero)-1):
TypeError: 'int' object is not callable
谢谢
【问题讨论】:
-
此错误与提供的代码不匹配。请提供实际代码。
-
对不起。这是错误。
if len(data)==(2(n_zero)-1): TypeError: 'int' object is not callable
标签: python arrays python-2.7 if-statement