I have a simple code which has a variable set to 0 in the beginning and then adds a number based on an input from a list. But whenever the addition is done, the output is still 0. I added a print after every statement to figure out the problem but it always outputs 0. I'm extremely inexperienced so I do apologize if the fix is simple. Here is the code:
HomeStartCodes = ["C1", "C2", "C3", "C4", "C5"]
HomeStartPrice = [1.5, 3.0, 4.5, 6.0, 8.0]
TotalPrice = 0.0
while True:
CCode = str(input("Please enter the first code of your journey "))
if (CCode not in HomeStartCodes):
print("Invalid, please enter C1. C2, C3, C4 or C5")
continue
else:
break
if CCode is str("C1"):
TotalPrice = TotalPrice + HomeStartPrice[0]
if CCode is str("C2"):
TotalPrice = TotalPrice + HomeStartPrice[1]
if CCode is str("C3"):
TotalPrice = TotalPrice + HomeStartPrice[2]
if CCode is str("C4"):
TotalPrice = TotalPrice + HomeStartPrice[3]
if CCode is str("C5"):
TotalPrice = TotalPrice + HomeStartPrice[4]
print (TotalPrice)
Output:
Please enter the first code of your journey C1
0.0