Python trainticket machine
<p>I am stuck at an excercise, I need to make a train ticket machine but I am just 1 week practicing in Python and I don't know how to start.</p>

<p>First I've got this:</p>

<pre><code>stations = ['Schagen', 'Heerhugowaard', 'Alkmaar', 'Castricum', 'Zaandam', 'Amsterdam Sloterdijk','Amsterdam Centraal', 'Amsterdam Amstel', 'Utrecht Centraal', ' âs-Hertogenbosch', 'Eindhoven', 'Weert', 'Roermond', 'Sittard', 'Maastricht']

begin = input('What is your starting station?: ')
</code></pre>

<p>but now it needs to check if the input is in stations, if its not it need to print:</p>

<pre><code>'This is not a station, your starting station will be: Schagen.'
</code></pre>

<p>Next step is asking for the final destination. If the final destination is in stations, after that it checks if the final destination has a higher index in the list then the begin station, if not, then print 'Wrong station' (or something like that) and add the last station in the list as final destination.</p>

<p>Next step needs to print the following:
- Name of the starting station</p>

<ul>
<li><p>Name of the destination station</p></li>
<li><p>names of stations which Are passed during the trip</p></li>
<li><p>Price of the trip (per station its like 5 euros.</p></li>
<li><p>and finally a summary;</p></li>
</ul>

<p>You get on the train on station:  <em>beginstation</em></p>

<p>Here the names of the stations we pass during our trip like:</p>

<p>-Heerhugowaard</p>

<p>-Alkmaar</p>

<p>You get out of the train in: ...</p>

<p>Could you give me some tips how to think like a programmer so I can realize this, the above exercise is pretty awesome, but very hard if you're just one week in to python/programming ;).</p>

<p>Regards,</p>

<p>In languages like C++ and Java, you use curly braces for different constructs. However, in Python, you use spaces or tabs for indentation instead of curly braces.</p>

<p>Here's a code that will get you started:</p>

<pre><code>src = input('Source station:')
dest = input('Destination: ')

if src in stations and dest in stations:
    for x in range((stations.index(src)+1), (stations.index(dest))-1):
        print(stations[x])
else:
    print('Invalid stations')
</code></pre>

<p>A <code>for-range loop</code> must be provided with 2 arguments: <code>initial value</code>, and <code>final value</code>.
Basically, we are finding the index of the source and destination stations from the stations list and then looping through the range of the values and at the same time, accessing all the elements from the <code>stations list</code>.</p>

<p>Try doing the rest of the stuff on your own! :) </p>

python python-3.x