Greeting to all,
I posted 2 days ago asking for help regarding making shuffle for a sub-list and I got great advice to regard it, which is to use some Python coding and I tried it, it was working, as I tested it in 2 laptops, both were working perfectly, today, I just restarted my laptop and run the python script, one of the laptops showing error now!! as I had no knowledge in Python I did not understand why!! any help would be really appreciated, thanks
which error do you get?
1 Like
Simply the shuffle not working!! and the result all “Null”
Hello @firas007noori,
Please try changing your b = {};
to b = [];
In Dynamo 2.0, we changed the way lists work in DesignScript, migrating from curley braces { }
to square braces [ ]
as we split up the old lists into real Lists and Dictionaries.
Lists now use square braces: [ ]
Dictionaries now use curley braces: { }
This switch also had us deprecate (Make redundant) some old nodes, including Count
in lieu of List.Count
.
Please also change n = Count(a) - 1;
to n = List.Count(a) - 1;
It should look as below:
And the DesignScript code snippet:
def shuffleFix(a : var[]){
return = [Imperative]{
b = [];
n = List.Count(a) - 1;
for (_ in a)
{
i = Math.Random(0, n);
b = List.AddItemToEnd(a[i],b);
a = List.RemoveItemAtIndex(a, i);
n = n -1;
}
return = b;
}};
1 Like