對於學校我有一個任務要完成,但我不知道該怎麼做。將一個列表中的值比較
我有兩個站,一個beginStation(start)和eindStation(end)。首先,我必須檢查他們是否在電臺列表中。這很好。 但是現在我必須檢查在同一個列表中eindStation是否在beginStation之後。
stations_place = {"Schagen" : 1, "Heerhugowaard" : 2, "Alkmaar" : 3, "Castricum" : 4, "Zaandam" : 5, "Amsterdam Sloterdijk" : 6, "Amsterdam Centraal" : 7, "Amsterdam Amstel" : 8, "Utrecht Centraal" : 9, "'s-Hertogenbosch" : 10, "Eindhoven" : 11, "Weert" : 12, "Roermond" : 13, "Sittard" : 14, "Maastricht" : 15}
eindStation = str(input("What is your end station? "))
if eindStation in stations_place:
print("good") #just to check if the code does it's job here
else :
print("This station isn't available, endstation is: Maastricht")
if eindStation >= beginStation in stations_place.values:
print("good") #just to check if the code does it's job here
else:
print("This station isn't available, endstation is: Maastricht")
我希望你們能幫助我。提前致謝!