Grasshopper

algorithmic modeling for Rhino

Hi,

I am trying to get the smallest value of a list. I know I could do a for loop for this but I want to use the python built in function min(). It gives me an error "Runtime error (ArgumentTypeException): float is not callable!"

This is the code I am running.

print min(3,4,3,6,67,78,7)

If I use the max() function it works fine. Any ideas of why this is not working?

Thanks,

M

Views: 7351

Replies to This Discussion

You should pass a list to min.

Try this:

print min([3,4,3,6,67,78,7])

http://docs.python.org/2/library/functions.html#min

min and max expect iterables (lists, tuples, arrays,...)  Place brackets or extra parentheses around your numbers to turn them into lists or tuples.

print min ( [3,4,5,6,67,78,7] )

Thanks Steve and Mostapha.

M

I should have said iterables. Thanks Steve.

RSS

About

Translate

Search

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service