Unit 2 Task 36 - Solution

Learn to code with step-by-step lessons. A place for students to work through programming fundamentals and build skills.

Solution - Task 36: Elevator floor hops

← Back to task


One possible program:

floor = 1

while True:
    target = int(input("Go to floor (0 to stop): "))
    if target == 0:
        break
    if target < 1:
        print("Invalid floor.")
        continue
    floor = target
    print("Now on floor", floor)

print("Elevator parked")