dimanche 24 octobre 2021

IF statement just responding to the most recent if statement's result [duplicate]

Hi i'm gonna try to explain this best I can so I have a task to make a pay phone price calculator based on day, duration and time call started. I did 2 of the if statements and realized whenever I put in my answers all it does is print the result off the most recent if statement and doesn't really listen to what I want it to do, its a bit hard to explain so ill just put my code my input and my result.

Code:

day = str(input('Enter the day the call started at: '))
start_time = float(input('Enter the time the call started at (hhmm): '))
duration = float(input('Enter the duration of the call (in minutes):'))
cost = duration

    if (start_time >= 08.00 and start_time <= 18.00 and day == "Mon" or "Tue" or "Wed" or "Thr" or "Fri"):
        cost = duration * 0.40
    
    if (start_time < 08.00 and start_time > 18.00 and day == "Mon" or "Tue" or "Wed" or "Thr" or "Fri"):
        cost = duration * 0.25
    
    print('$' + str(cost))

My inputs:

1: Fri, 2350, 22.  2: Sund, 2350, 22.

My results:

1: $5.5.  2: $5.5.

As you can see it didn't even do whats inside the print statement it just gave me the result of the outcome of the previous if statement I also tried removing the "and day ==" and whats after and all that did is make the first print statement work fine while the second doesn't work it just prints my original duration so I think I messed up bad. (I hope I didn't make you lose brain cells explaining im very bad at it)

Aucun commentaire:

Enregistrer un commentaire