0

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])
Mad Physicist
  • 107,652
  • 25
  • 181
  • 264
Some Name
  • 561
  • 6
  • 18

1 Answers1

2

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.

Community
  • 1
  • 1
Kalpesh Dusane
  • 1,477
  • 3
  • 20
  • 27