0
week = int(input("Enter The Week Your Stay Starts "))

if week not in range(23,39):
    print("You Cannot Make Bookings Outside Of Weeks 23-39")
elif week in range(23,39) and week in range(23,26) or week in range(36,39):
    print("Peak Rates Apply Do Not Apply To The Week You Have Selected")
    onoff = False
elif week in range(23,39) and week in range(27,35):
    print("Peak Rates Apply To The Week You Have Selected")
    onoff = True
    print("Something Went Wrong Please Try Again And Enter Correct Details")        

In summary this code asks the user which room they want. This is then decided if it is in peak or off peak (which decides the price) by the week they have inputted. If the user inputs something outside of the ranges 23-39 it should not allow the user to enter this. The problem i am having is that I am unsure of how to loop it so it asks the user which week they want after they have inputed weeks outside of 23-39. I was thinking of the REPEAT....UNTIL or the WHILE...DO...ENDWHILE loops but im not sure if it'll work

  • 2
    Have you heard of the `break` statement? https://docs.python.org/3.7/tutorial/controlflow.html#break-and-continue-statements-and-else-clauses-on-loops – darthbith Sep 10 '18 at 03:08
  • Just try implementing this code with a loop and break statement, and post a question if it doesn't work. – sid-m Sep 10 '18 at 03:14
  • You can use an infinite loop and then `break` the loop when your input is validated. – Mushif Ali Nawaz Sep 10 '18 at 03:14

0 Answers0