Q:

How to modify part of a list of floats?

I have a list named lon_list that contains a number of float values ranging from 0 to 360. I am interested in subtracting 360 from any floats greater or equal to 180 in the list. How would I do this? 
Here is my current attempt:
for x in lon_list:
   if x>=180:
      x-360
lon_list

A:

Try this:
lon_list = [12, 13.50, 183.54, 205.80]
lon_list = [x-360 if x>= 180 else x for x in lon_list]
print(lon_list)

Output
[12, 13.5, -176.46, -154.2]

