#!/usr/bin/env python3 #title :FA-3.py #description :Final Assignemt: NS-kaartautomaat #author :Marcel Haazen #email :marcel@haazen.xyz #date :04-11-2019 - 11:58 #edit_date :04-11-2019 - 11:58 #version :0.1 #usage :python3 FA-3.py #notes : #python_version :3.7.4 #============================================================================== import string stations = ["Schagen", "Heerhugowaard", "Alkmaar", "Castricum", "Zaandam", "Amsterdam Sloterdijk", "Amsterdam Centraal", "Amsterdam Amstel", "Utrecht Centraal", "'s-Hertogenbosch", "Eindhoven", "Weert", "Roermond", "Sittard", "Maastricht"] def inlezen_beginstation(stations): while True: start = string.capwords(str(input("What is your starting station? "))) if start in stations: break else: print("\nThis train does not come in:", start, end= "." "\n") return start def inlezen_eindstation(stations,start): while True: ends = string.capwords(str(input("What is your starting station? "))) if ends in stations: if stations.index(ends) > stations.index(start): break else: print("\nThe endstation is before the current station\n") else: print("\nThis train does not come in:", ends, end= "." "\n") return ends def omroepen_reis(stations, beginstation, eindstation): stops = stations.index(eindstation) - stations.index(beginstation) print("\n \nHet beginstation", beginstation, "is het", (str(stations.index(beginstation)+ 1) + "e"), "station in het traject.") print("Het eindstation", eindstation, "is het", (str(stations.index(eindstation)+ 1) + "e"), "station in het traject.") print("De afstand bedraagt", stops, "stations(s).") print("De prijs van het kaartje is", 5 * stops, "euro.") print("\nJij stapt in de trein in:", beginstation) for i in range((stations.index(beginstation)), (stations.index(eindstation))): i += 1 if i != stations.index(eindstation): print(" -",stations[i]) print("Jij stapt uit in:", eindstation) beginstation = inlezen_beginstation(stations) eindstation = inlezen_eindstation(stations, beginstation) omroepen_reis(stations, beginstation, eindstation)