I am trying to pull up the same index position from another list after I have successfully indexed an item in a different list.
Basically, I have a list of fruits and their prices during the weekdays and during the weekend. The very exact fruit is being taken as an input and if the fruit is in the list then I am indexing it. The day of the week is also an input and if the day is in the workdays I want to take the same index position from the list of the weekdays prices in order to correspond with the very exact fruit's index position. Same as if the day is Saturday or Sunday - taking the index position from the weekend price list.
Here is the code:
fruits=["banana","apple","orange","grapefruit","kiwi","pineapple","grapes"]
weekdays=["Monday","Tuesday","Wednesday","Thursday","Friday"]
weekdays_price=[2.50,1.20,0.85,1.45,2.70,5.50,3.85]
weekend=["Saturday","Sunday"]
weekend_price=[2.70,1.25,0.90,1.60,3,5.60,4.20]
fruit=input()
day=input()
quantity=float(input())
if fruit in fruits:
fruit_index=fruits.index(fruit)
if day in weekdays:
pass
#taking the same index from weekdays_price and multiplying it's item value by the quantity
elif day in weekend:
pass
#taking the same index from weekend_price and multiplying it's item value by the quantity
else:
print("error")
else:
print("error")
So for example if the user enters "apple","Monday" and 2 Python should print out 2.40 ("apple" index position is 1, "Monday" is in weekdays so we are taking index position 1 from weekdays_price (1.20) and multiplying it by the quantity (2)).