Tags: 136-14 Finding Longitude and Latitude Function

Hello, the directions for the determining longitude function in 14/16 of Data Cleaning Walkthrough states it “Uses the regular expression on the previous screen to extract the coordinates.”, but the hint shows the location has been changed from an exact address ("1110 Boston Road\nBronx, NY 10456\n) to loc. How do we decide which example to follow?
Also, what do [0] and [1] refer to in the brackets? I thought it was [0] latitude and [1] longitude, is this correct? What do 0 and 1 signify in the expression lon = coords[0].split(",")[1].replace(")", "").strip()?

1 Like

Please make sure to share the link to Mission and apply the necessary tags to the question and not in the question title.

Break down that code line, and print out the needed parts one by one (with the 0 and 1 and without them) and see what output you get. That will help you figure out what the 0 and 1 signify.

1 Like

coords[0] : the variable coords contains a list with only one element (the extracted lat and lon as a tuple). The split() function returns a list of two elements (the lat and lon), the index [1] at split[1] will return the second element in the list which is the lon. Sometimes method/function chaining can get confusing, hope this helps.