python中的循环的最小/max
如果需要获取此循环的最小值,最大和总和,请如何运行此代码?
我成功地运行了这个循环,但是当我试图获取最小值时,Max Am获得“ int”“对象是不可能的”。
对于范围(1,1000)的价值: 打印(最小值(值))
谢谢
Please how can I run this code if I need to get the MIN, MAX and SUM of this Loop?
I ran this loop successfully but when I was trying to get the MIN and MAX am getting "int" "the object is not iterable".
for value in range(1,1000):
print(min(value))
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
是的,因为Min()函数返回具有最低值的项目,或者在峰值中具有最低值的项目。意味着,当您运行循环时,您的获得I仅为1,并且由于单个值而进行最小迭代。只是您没有任何比较价值。尝试添加更多代码。
例子,
Yes, because The min() function returns the item with the lowest value, or the item with the lowest value in an iterable. Means when you are running your loop your getting i as 1 only and min iterating due to single value. simply you're not having any value for comparison. try to add more code.
example,
MIN在可估量的列表中找到最小值,最低([1,2,3,4])
您正在尝试找到单个整数的最小值,即min(1),因为循环从您正在通过的值范围返回每个值
Min finds the minimum value in an iterable e.g. a list, min([1,2,3,4])
You are trying to find the minimum value of a single integer i.e. min(1) because the loop returns each value from the range of values you are iterating through