Correction of angles (Python beginner)

Hello forum

After using Dynamo for some time I want to learn to use Python, but so far with very little success. I hope you will be able to help me:

I have a list of values for angles and some are above 360 degrees. If a value is above 360 i want to subtract 360 from that number

The list 10, 10 , 375, 35 should be turned into 10, 10, 15, 35

I tried to make a Python script for this but so far i havent been able to. My script so far looks like this:
import clr
from Autodesk.DesignScript.Geometry import *

angles = IN

for i in range(0,len(angles)):
if angles[i]>360

OUT = realangles[]

Im well aware that I might be way off, but I hope I can get some help to get on the right track.

Maybe something like this will work better?

angles = IN[0]
OUT = []

for angle in angles:
	if angle > 360:
		OUT.append(angle - 360)
1 Like

Yes perfect! Thanks Einar.

This might (as well) be a stupid question, but why do I have to write.

“angles = IN[0]” and not “angles = IN[ ]”?

If I write OUT= [0] I get the same results but with a “0” as the first value of the output list

Thats because IN[0] is the first port on your python node. IN is a list of all the ports. Maybe this example makes it clearer:

Yes it makes much more sense now. Thanks very much for the help!