Python Forum
Looping unknowns with user input hw question
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Looping unknowns with user input hw question
#1
Hello, I am having some difficulty with a problem through Grok Learning. I've been stuck on it for two days now. I think I'm close to a solution, but I'm not getting the in-between outputs as I need to. I tried using the range function but am given coordinates or some reason. So I won't post that code, and will post the one that is closest to what the possible answer could be.

Here is the question;
"The lift is broken! It can still go up and down, but doesn't display what floor it's at anymore, which is causing confusion for people trying to use it.

Write a program that will display the floor numbers on an elevator that is going up. Your program should read in the current floor and read in the destination floor, which will always be higher than the current floor. Your program should print out each of the floor numbers in-between."

What the outputs should to be;
example1
Current floor: 3
Destination floor: 6
Level 3
Level 4
Level 5
Level 6
​
example2
Current floor: 1
Destination floor: 2
Level 1
Level 2
My current answer code is;
floor = int(input("Current floor: "))
dfloor = int(input("Destination floor: "))
while floor <= dfloor:
  if dfloor % floor == 0:      
    print("Level", floor)
  floor = floor + 1
print('')
However, my output comes to just the selected floors;
Current floor: 3
Destination floor: 6
Level 3
Level 6
Reply


Messages In This Thread
Looping unknowns with user input hw question - by Turkejive - Sep-30-2018, 08:46 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
Question Simulate an answer based on user input [Beginner needs guidance] Bombardini 1 1,306 Nov-12-2022, 03:47 AM
Last Post: deanhystad
  Print user input into triangle djtjhokie 1 2,401 Nov-07-2020, 07:01 PM
Last Post: buran
  Changing Directory based on user input paulmerton4pope 13 8,113 Aug-14-2020, 11:48 AM
Last Post: GOTO10
  how to add the user input from file into list wilson20 8 4,349 May-03-2020, 10:52 PM
Last Post: Larz60+
  Writing a function that changes its answer based on user input SirRavenclaw 2 2,830 Dec-21-2019, 09:46 PM
Last Post: Clunk_Head
  Print the longest str from user input edwdas 5 4,184 Nov-04-2019, 02:02 PM
Last Post: perfringo
  Question about running comparisons through loop from input value Sunioj 2 2,421 Oct-15-2019, 03:15 PM
Last Post: jefsummers
  how to add user input to a dictionary to a graph KINGLEBRON 3 3,059 Jul-31-2019, 09:09 PM
Last Post: SheeppOSU
  New to Python - tiny coding assistance on user input function and assign to variable Mountain_Duck 1 2,529 Mar-23-2019, 06:54 PM
Last Post: Yoriz
  Extracting list element with user input valve 1 2,593 Mar-11-2019, 07:37 PM
Last Post: Yoriz

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020