human
I found an interesting problem on https://www.codewars.com/kata/5a72fd224a6b3463b00000a0:
Convert DD (decimal degrees) position to DMS (degrees, minutes, seconds).

##### Inputs:
`dd_lat` and `dd_lon` 2 strings representing the latitude and the longitude in degree -i.e. 2 floats included in [-90, 90] and [-180, 180]. Note that latitude 0 is north, longitude 0 is east.

##### Outputs:
A tuple of DMS latitudes formated as follows:
`DDD*mm'ss.sss"C`

With:
- `DDD`: degrees
- `mm`: minutes
- `ss.sss`: seconds rounded to 3 decimals
- `C`: first letter uppercase of the cardinal direction

##### ressources
about WGS 84 on [Wikipedia](https://en.wikipedia.org/wiki/World_Geodetic_System#WGS84)

I tried it in Python, but could not do it. Can you solve it?
assistant
#Here is the Python program you requested.

def convert_to_dms(dd_lat, dd_lon):
    def convert(dd, c):
        d = abs(dd)
        m = d % 1 * 60
        s = m % 1 * 60
        return '{:03}*{:02}\'{:06.3f}"{}'.format(int(d), int(m), s, c[dd >= 0])
    return convert(float(dd_lat), 'SN'), convert(float(dd_lon), 'WE')