Für die Schule muss ich einen Auftrag machen, aber ich weiß nicht, was ich machen soll.Werte in einer Liste vergleichen
Ich habe zwei Stationen, eine BeginStation (Start) und eindStation (Ende). Zuerst musste ich prüfen, ob sie in einer Senderliste stehen oder nicht. Das ging gut. Jetzt muss ich allerdings prüfen, ob in der gleichen Liste die eindStation nach der beginStation kommt.
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")
Ich hoffe, Sie können mir helfen. Danke im Voraus!