I was making a program that would calculate the money to be payed in a parking lot(not a real one). I have 2D arrays storing the data of the days of the week ([day, max hours, price per hour]), but when I try to check the day, I get a
TypeError: 'int' object is not subscriptable
The error was in line 15.
Here is the code for reference, although unfinished:
price_morning = [["Monday", 8, 2.00], ["Tuesday", 2, 10.00], ["Wednesday", 2, 10.00], ["Thursday", 2, 10.00], ["Friday", 2, 10.00], ["Saturday", 2, 10.00], ["Sunday:", 4, 3.00]]
price_midnight = [[8, 2.00], [8, 2.00], [8, 2.00], [8, 2.00], [8, 2.00], [8, 2.00], [8, 2.00]]
day = input("Day: ")
time = input("Time: ")
hours_of_stay = input("Hours of stay: ")
quest = input("Do you have a frequent parking number? ")
if quest == "Yes" :
f_p_n = input("Frequent Parking Number: ")
else :
f_p_n = 0
"Calculation: "
if int(time) < 16 :
for i in range(len(price_morning)):
if price_morning[i[0]] == day:
if price_morning[i[1]] >= hours_of_stay:
price = int(hours_of_stay) * int(price_morning[i[2]])
Is there anyway I could fix it?
Note:
f_p_n stands for frequent parking number, and will be used later on.