155. Python Program to Make a Ticket Machine with finally
Mediumelse and finally
Overview
Use all four parts of a try statement: try, except, else and finally.
Problem Statement
A ticket costs 50. Read the number of tickets (a whole number) and print the total, like this for 3:
Total: 150
- If the input is not a whole number, print
Please type a whole number - If the number is less than 1, print
Buy at least one ticket
In every case, the last line is:
Thank you for visiting
Use input() with no prompt text: the tests type the input for you, and a prompt would end up in your output.
Input
One value. Example:
3
Output
The output for that example:
Total: 150
Thank you for visiting
The tests try 4 different inputs.