Python Forum
Simple statistics with range function
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Simple statistics with range function
#1
Hello,

I am sure this is easy for you guys, i am new here.

I try to use a range function and then get some simple statistics out of this (min,max,sum). I get the list but get an error for the min number.

Thanks.

for numbers in range(21):
  print(numbers)
print(min(numbers)) 
Reply
#2
The for loop variable (numbers in this case) gets one value from the range generator each time through the loop. So at the end of the loop, numbers is equal to 21. You can't take the min of one number, you need to either supply a sequence or multiple arguments.
Craig "Ichabod" O'Brien - xenomind.com
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures
Reply
#3
Thanks a lot !!!
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Behavior of statistics.mean cametan 4 476 Jan-30-2024, 09:20 PM
Last Post: DeaD_EyE
  matplotlib x axis range goes over the set range Pedroski55 5 3,111 Nov-21-2021, 08:40 AM
Last Post: paul18fr
  Writing a function to calculate time range in Unix Epoch Time t4keheart 2 2,934 Jul-15-2020, 01:55 AM
Last Post: t4keheart
  got SyntaxError while building simple function zarize 2 2,079 Feb-14-2020, 10:51 AM
Last Post: zarize
  Define a range, return all numbers of range that are NOT in csv data KiNeMs 18 6,879 Jan-24-2020, 06:19 AM
Last Post: KiNeMs
  Cannot get simple i/o to function. jerryi 10 6,645 Jul-27-2019, 06:22 PM
Last Post: jerryi
  Need help with a simple function WorldPark 4 2,618 Apr-26-2019, 12:28 PM
Last Post: perfringo
  Range Function OceanJeff40 1 2,684 Feb-17-2019, 09:34 PM
Last Post: buran
  Why this simple function doesnt work? blackknite 8 3,904 Jan-05-2019, 12:32 PM
Last Post: buran
  Cannot print range function AndyArsalan 2 2,815 Sep-11-2018, 07:01 PM
Last Post: buran

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020