title: While calculating Haversine distance, the main for loop is running only once
body: <p>I have a data frame consisting of city names, longitudes and latitudes. What I want to do is create a data frame of cities around a city in a 100km radius. What I mean by this is that If my data looks like</p>
  <pre><code>City    Latitude Longitude
  Delhi       lat1     long1
  Noida       lat2     long2 
  Gurgaon     lat3     long3
  Mumbai      lat4     long4
  </code></pre>
  <p>After processing I want my data to look like:</p>
  <pre><code>City    nearby city  distance
  Delhi       Noida       x1
  Delhi       Gurgaon     x2
  Noida       Delhi       x3 
  Noida       Gurgaon     x4
  Gurgaon     Delhi       x5
  Gurgaon     Noida       x6
  </code></pre>
  <p>Mumbai gets omitted from this because of the condition that I only want to see the cities around a city within a 100km radius of said city. For this reason I'm using Haversine formula. Here is my code:</p>
  <pre><code>for idx, val in enumerate(city_list):
      lat1 = city_latitude[idx]
      long1 = city_longitude[idx]
      for next_idx, next_val in enumerate(copy_city_list):
          if val == next_val:
              pass
          else:
              lat2 = city_latitude[next_idx]
              long2 = city_longitude[next_idx]
              lat1, long1, lat2, long2 = map(radians, [lat1, long1, lat2, long2])
              # haversine formula
              dlon = long2 - long1
              dlat = lat2 - lat1
              a = sin(dlat/2)**2 + cos(lat1) * cos(lat2) * sin(dlon/2)**2
              c = 2 * asin(sqrt(a))
              # Radius of earth in kilometers is 6371
              km = 6371 * c
              if(km &gt; 100):
                  pass
              else:
                  city.append(val)
                  near_by_city.append(next_val)
                  distance.append(km)
      print(&quot;Record appeneded&quot;)
  </code></pre>
  <p>I split my data into 3 lists, <code>city_list</code>,<code>city_latitude</code>,<code>city_longitude</code> because when I first did it using a pandas dataframe, I got an output after nearly 10 minutes as I have 3368 records. Splitting it into lists and performing the calculations is giving me an output in 2-3 minutes but the issue remains the same. The main loop only performs one iteration out of 3368 and the appended values are also getting jumbled.</p>
  <p>The output I want to see is <code>Delhi,Delhi,Noida,Noida,Gurgaon,Gurgaon</code> in my <code>city</code> list and <code>Noida,Gurgaon,Delhi,Gurgaon,Delhi,Noida</code> in my <code>near_by_city</code> list. Instead I see <code>Noida,Gurgaon</code> in my <code>city</code> list and <code>Delhi,Delhi</code> in my <code>near_by_city</code> list.</p>
  <p>Where am I going wrong?</p>