def get_turn_direction(gmaps): #calling the google maps string "gmaps" gmaps_array = lower(gmaps).split(); #Convert to lowercase and split words if gmaps_array[1]=="left": if gmaps_array[0]=="turn": return "turn_left" elif gmaps_array[0]=="bear": return "bear_left" elif gmaps_array[0]=="exit": return "bear_left" else: return "turn_left" elif gmaps_array[1]=="right": if gmaps_array[0]=="turn": return "turn_right" elif gmaps_array[0]=="bear": return "bear_right" elif gmaps_array[0]=="exit": return "bear_right" else: return "turn_right" else: if gmaps_array[0]=="merge": return "merge" elif gmaps_array[2]=="left": #i.e. "Take first left" return "turn_left" elif gmaps_array[2]=="right": return "turn_right" elif gmaps_array[0]=="exit": #with no side specified, assume right exit return "bear_right" elif gmaps_array[0]=="continue": return "straight" else: #Catchall for other commands that I haven't anticipated return "don't_know"