Graph Search Project help


#1

SkyRoute

So when i run the code and put correct inputs i.e. “a” and “b” i should get:

(‘Marine Building’, ‘Scotiabank Field at Nat Bailey Stadium’)

instead i get :

(‘Marine Building’, None)

i checked out the get_end() function in the walkthrough video (Task 11: 17.03) our codes are the same however his code works completely fine. What am i doing wrong here?

from graph_search import bfs, dfs
from vc_metro import vc_metro
from vc_landmarks import vc_landmarks
from landmark_choices import landmark_choices

# Build your program below:

landmark_string = ""

for letter, landmark in landmark_choices.items():
  landmark_string += "{0} - {1}\n".format(letter, landmark)
  
def greet():
  print("Hi there and welcome to SkyRoute!\n")
  print("We'll help you find the shortest route between the following Vancouver landmarks:\n" + landmark_string)
  
def skyroute():
  greet()
  

# ASK THE USER FOR A STARTING POINT #
def get_start():
  start_point_letter = input("Where are you coming from? Type in the corresponding letter: ")
  
  if start_point_letter in landmark_choices:
    start_point = landmark_choices[start_point_letter]
    return start_point
  else:
    print("Sorry, that's not a landmark we have data on. Let's try this again...")
    return get_start()
    
# ASK THE USER FOR AN END POINT #
def get_end():
  end_point_letter = input("Ok, where are you headed? Type in the corresponding letter: ")
  
  if end_point_letter in landmark_choices:
    end_point = landmark_choices[end_point_letter]
  else:
    print("Sorry, that's not a landmark we have data on. Let's try this again...")
    return get_end()
 

#
def set_start_and_end(start_point, end_point):
  if start_point is not None:
    change_point = input("What would you like to change? You can enter 'o' for 'origin', 'd' for 'destination', or 'b' for 'both': ")
    
    if change_point == "b":
      start_point = get_start()
      end_point = get_end() 
    elif change_point == "o":
      start_point = get_start()
    elif change_point == "d":
      end_point = get_end()
    else:
      print("Oops, that isn't 'o', 'd', or 'b'...")
      set_start_and_end(start_point, end_point)
    
  else:
    start_point = get_start()
    end_point = get_end()
  
  return start_point, end_point


  



print(set_start_and_end(None, None))

#3

simple fix, you are missing the return statement one line below your end_point variable declaration. I also used if end_point_letter in landmark_choices.keys(): to be specific