Strange little issue in 'SkyRoute' when removing sets

Hi all. I’m filling out the project, and I’ve run into a weird problem. It shouldn’t prevent the program from functioning but it’s still doing something it shouldn’t be.

My problem is that when I detract the under construction set from the neighbours set, it gets bizarre. I’ll show you:

stations_under_construction = ['Granville', 'Columbia']

def get_active_stations():
  updated_metro = vc_metro
  for station_uc in stations_under_construction:
    for current_station, neighboring_station in vc_metro.items():
      if current_station not in stations_under_construction:
        updated_metro[current_station] -= set(stations_under_construction)
      else:
        updated_metro[current_station] = set(current_station)
  return updated_metro

The -= is done according to the actual hint. Printing updated_metro, I can see that nowhere links to Columbia or Granville. However, Columbia and Granville in the graph have been entered as themselves, but as a set of the individual letters!

‘Columbia’: {‘a’, ‘i’, ‘m’, ‘C’, ‘u’, ‘o’, ‘l’, ‘b’}
‘Granville’: {‘a’, ‘v’, ‘i’, ‘G’, ‘e’, ‘n’, ‘l’, ‘r’}

I’m just curious about why it works that way and how to go about fixing it.

Try switching not in to != if current_station not in stations_under_construction:, I tried this with your code and it seemed to fix it. I’m still trying to reason out why it makes the text characters split.

That fixed it, but it is puzzling isn’t it?

Oh that’s what it is. Set(current_station) !
Current station is always just a single string, when you let it equal a set it’ll start parsing it weird.

My process for figuring it out was to put tracers of every item and a counter that prints ******** iteration 1, *********iteration 2.

That helped me see it was only happening on certain triggers, which led me to play around with the if/else statements. Figured it was only the else statements, then it was easy once the problem was focused.

I don’t know if the get help video put that in there, but you should leave a note if it did!!