首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >带有大量Raw_Inputs的Python随机数,调试

带有大量Raw_Inputs的Python随机数,调试
EN

Stack Overflow用户
提问于 2016-04-03 19:46:14
回答 1查看 45关注 0票数 0
代码语言:javascript
复制
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行带有所有()的

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2016-04-03 19:47:47

问题很简单:您使用m而不是n在raw_input (中间行)中做了一个错误。

另外,randint应该使用2个参数(假设这是python),因此您缺少了一个逗号。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/36390299

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档