How to convert negative longitude to a positive in python?
<p>I am reading in a text file and extracting values to display the longitude but from the text file, it is a negative value and need for it to be positive.</p>

<p>A sample of the text file that I have, in the format of (DDDMMSS.SS), named coordinates.txt:</p>

<pre><code>Longitude : -0780417.04
</code></pre>

<p>Basically, it needs 359 added to the first 3 numbers (DDD or degrees), 59 to the next 2 numbers (MM or minutes) and 60.00 to the last 4 numbers (SS.SS or seconds).</p>

<p><strong>Note</strong> : each split of numbers is a negative value</p>

<p>The desired output is:</p>

<pre><code>281 55 43.0
</code></pre>

<p>The code that I have currently is:</p>

<pre><code>with open('coordinates.txt', 'r'): as f:
    for line in f:
        header = line.split(':')[0]
        if 'Longitude' in header:
            longitude = line.split(':')[1].strip()[1:4] + " " + line.split(':')[1].strip()[4:6] + " " + line.split(':')[1].strip()[6:10]
            print longitude
</code></pre>

<p>How would I go about adding those additions to my current code? </p>