vendredi 22 octobre 2021

Nested else and if methods

I just got started in Python programming. This week, we've been learning basic commands such as for, while, if and else. The point is that I got stuck at a point of the following exercise:

I am to design a programme which has to ascertain whether the day entered by the user is Monday - Friday or at the weekend. If the entered value is either Saturday or Sunday, then it has to display 'Congratulations, you're in the low-cost section'. If the value entered is other than that and is any value Monday-Friday, only then the user has to be asked for the hour. Depending on the hour value entered, it has to display different messages (only 3 options available).

My attempt at this has been the following:

Code ProcessOutput

As you'll see if you type in 'Saturday' it asks you for the hour when it shouldn't! Do you have any thoughts on how to solve this?

Aucun commentaire:

Enregistrer un commentaire