Search code examples
pythoncountdown

Count down floors


I have nearly fixed this to the point it needs, but one thing I can't seem to get is the floor I'm on. The code needs to count down the floors from say floor 2 to floor 6 including the floor 2 in the countdown. Mine only goes from next floor up to the one down, say floor 3 to floor 6. I need help to fix this please.

floor = int(input('Current floor: '))
destination = input('Desination floor: ')
while floor <= 5:
  floor = floor + 1
  print(floor)

Solution

  • Print before you increment floor (floor = floor + 1). You left the while loop at 5, which I assume should be the destination. A final print or a modification to the while loop may be needed.