this is my first time posting, and I'm not fond of asking for help but in this case I've been working on it for way too long for something I think should be simple.. I have looked a little bit on the site and couldn't find something that would solve my problem. The closest i found was if-else statement and code exit My code is:
def count () -> object:
floor = int(input("Please enter a number between 1 and 15:\n"))
if 13 <= floor <= 15:
actualfloor = floor - 1
print("Actual Floor: " + str(actualfloor) + "\n")
else:
if 12 >= floor >= 0:
actualfloor = floor
print("Actual Floor: " + str(actualfloor) + "\n")
else:
print("Invalid Number, Please select a number between 1 and 15.\n\n")
count()
count()
What I am trying to do is have it so that if the user enters a number such as "0" or " " or anything above "15" that the code will exit. The only thing I could see was the For While loops, but I don't know how I would implement that with the code I've written. So my question is, how can I create an exit with what I have? Using basic python strategies. My logic is thinking if # > 15, exit, else continue Any help would be greatly appreciated.
Aucun commentaire:
Enregistrer un commentaire