Hello Dynos,
I discovert a nice short code:
x = IN[0]
x.sort(key = len)
OUT = x
Which other keys (= len
)can i generate? like:
can i say key = startwith lowercase
or uppercase
does anyone know more “vocabulary”?
KR
Andreas
Hello Dynos,
I discovert a nice short code:
x = IN[0]
x.sort(key = len)
OUT = x
Which other keys (= len
)can i generate? like:
can i say key = startwith lowercase
or uppercase
does anyone know more “vocabulary”?
KR
Andreas
for ‘contains’ you can use ‘in’ statement ( if sub_string in string: )
there is also ‘startswith’ and ‘endswith’ ( string.startswith(‘beginning’) )
One more handy thing for the sort function are lambda expressions. They allow you to do things like this:
a.sort(key = lambda x: x.Name )
or
a.sort(key = lambda b: b.x + b.y + b.z )