 # 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:

Problem:
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

Example:
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
realangles[i]=angles[i]-360
else
angles[i]
realangles[i]=angles[i]

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
OUT = []

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

Yes perfect! Thanks Einar.

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

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

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

Thats because IN 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!