Reputation: 571
Trying to make one of my very first programs. Tried to convert to int
, didn't work.
Getting this error:
list indices must be integers or slices, not tuple
stations = ['Schagen', 'Heerhugowaard', 'Alkmaar', 'Castricum', 'Zaandam', 'Amsterdam', 'Sloterdijk', 'Amsterdam Centraal', 'Amsterdam Amstel', 'Utrecht Centraal', '’s-Hertogenbosch', 'Eindhoven', 'Weert', 'Roermond', 'Sittard', 'Maastricht']
IndEind = stations.index(eindStation)
IndBegin = stations.index(beginStation)
intBegin = int(IndBegin)
intEind = int(IndEind)
print('stations[0]: ', stations[intBegin, intEind])
Upvotes: 0
Views: 2425
Reputation: 1485
Give print('stations[0]: ', stations[intBegin: intEind])
instead of print('stations[0]: ', stations[intBegin, intEind])
to understand in detail about Python's slice notation check this out : Explain Python's slice notation
For printing on separate lines give:
for i in stations[intBegin:intEind]:
print(i)
Hope this helps.
Upvotes: 2