import random
count=0
other=0
inp=raw_input('Enter number of #s: ')
bottom=raw_input('Enter min: ')
upper=raw_input('Enter max: ')
middle=raw_input('Provide middle number')
for x in range(int(inp)):
a=random.randint(((int(bottom)(int(upper)))))
#print a
if (a>middle):
count=count+1
elif (a<middle):
other=other+1
print count, "numbers over 1500"
print other, "numbers under 1500"好的,所以我试图使“用户”能够提供运行代码所需的所有变量。以前我犯了一个愚蠢的拼写错误。修复了我现在接收到的错误(TypeError:'int‘对象不可调用),错误归因于第9行,第9行带有所有()的
发布于 2016-04-03 19:47:47
问题很简单:您使用m而不是n在raw_input (中间行)中做了一个错误。
另外,randint应该使用2个参数(假设这是python),因此您缺少了一个逗号。
https://stackoverflow.com/questions/36390299
复制相似问题