Grasshopper

algorithmic modeling for Rhino

Hi everyone

im trying to import some modules but it seems not to work. does anyone know the procedure to accomplish this 

thanks

Views: 335

Replies to This Discussion

Not an answer to your first question but if you're trying to get the length of the list try len(x)

Make sure to right click on x input and change the access to List Access

Thanks Mostapha, I want to get the most common element in the list, which in this case would be 8. I think with the len() function I would get the lenght of the list.

You can use Python's collections module for that. Try this:

from collections import Counter
testList = [1,2,4,5,5,6,7,8,8,8,8,8,8]

mostOccurred,numOfOccurance = Counter(testList).most_common(1)[0]

print "%d and for %d times" % (mostOccurred, numOfOccurance)

Similar question on stackoverflow: http://stackoverflow.com/questions/6987285/python-find-the-item-wit...

One of my personal favorites that one :)

This is exactly what i was looking for. Thanks again
I owe my life

RSS

About

Translate

Search

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service