In my code I have variables e.g Up1, Up2 .....so on. It is related to buying tickets for train. The user inputs the time in form of integers as seen below but not full time in form of (hh:mm) I want python to take integer input from user, attach it with string 'Up'(and here the integer) to create the variable mentioned above e.g. Up9 for 9:00 Now python needs to find the number of seats for that particular train and compare if the number of seats entered by user is within the available range of seats. However in the line (while Tickets_to_buy > Uptime_:) the Uptime_ is a string and python rejects it. How to convert this str(Uptime_) to a variable name so rather than str(Up9) it will become a variable (Up9) and python fetches its value to compare it with other variable ...
Uptime = int(input('''Please enter the time of uptime from below:
9 for 09:00
1 for 11:00
3 for 03:00
5 for 15:00'''))
Downtime = int(input('''Please enter the time of downtime from below:
0 for 10:00
2 for 12:00
4 for 14:00
6 for 16:00'''))
Uptime_ = ('UP' + str(Uptime))
Tickets_to_buy = 0
while Tickets_to_buy > Uptime_:
Tickets_to_buy = int(input('Please enter number of tickets you would like to buy. It should be less than', Uptime_))