I’ve just started out using python, so I apologies in advance if nothing makes sense!
I’ve made a couple of scripts to aid dynamo, and just to see if i could make them for learning purposes.
The one below works with a list, but not a list of lists. It is used to remove all the chars a-z from a string:
import re a =  for i in IN: b = re.sub("[a-zA-Z]+", "", i) a.append(b) #Assign your output to the OUT variable. OUT = a
When I input a list of lists it returns ‘null’ with an error saying:
Warning: IronPythonEvaluator.EvaluateIronPythonScript operation failed.
Traceback (most recent call last):
File “”, line 7, in
TypeError: expected string for parameter ‘string’ but got ‘list’
A different script works with lists in my IDE but not in dynamo, it just returns null.
So in my IDE i have this:
y = [1234, 5678] def digit_test(n): sum_n =  for i in n: total = 0 while i>0: total += (i%10) i = i//10 sum_n.append(total) return sum_n print digit_test(y) >>> returns [10, 26]
But in dynamo I have the below, as the above returns null in dynamo:
import clr n = IN def digit_sum(n): sum_n = 0 while n>0: sum_n += (n%10) n=n//10 return sum_n OUT = digit_sum(n)
Does anyone have any idea? I’m getting the hang of using python in my IDE, but struggling a tad with it in dynamo, so i’m just trying to get used to using it in the dynamo environment as well.
Thanks for reading,