Hello everyone,
I am trying to select random indexes using Python’s random integer generator. However I want to store these indexes so that if I select the same index i would be able to check if that is in the same list or not.
Hello everyone,
I am trying to select random indexes using Python’s random integer generator. However I want to store these indexes so that if I select the same index i would be able to check if that is in the same list or not.
Hello,
I’m not sure if I understand you correctly. Usually you can google Python specific issues or question by typing in saying : “Python check if item is in list” etc. Usually you will get a reference on Stack overflow like such: https://stackoverflow.com/questions/7571635/fastest-way-to-check-if-a-value-exist-in-a-list ->
if (mySelectedItem in randomValues) :
doSomething()
However looking at your code its clear you are pretty new to programming. You may walk through some Python tutorials first, learning the language.
Hello Tom,
thanks for the answer, I want to initialize a list and a set before the code given above so that my list and the set are outside the for-loop. (so that i can store a list of sets -endpoints of curves-) my main issue is that when i initialize the list and the set in Python Script it for some reason passes these to the net one as a string type.
How can I avoid this? Thanks,
Sorry I don’t understand.
lists are initialised like this
randValues = [2,4,12,42,56,66,201,399,400,5000]
or
randValues = []
randValues.append(3)
randValues.append(4)
for val in randValues:
doSomething()
a = randValues
If you pass values from outside a component you need to right click onto your input parameter and set Access to List, then an input parameter (for instance named x
) will be handled as a list and not item.
oh that’s great, I will try changing the input parameter to Access to List, thanks!