How to find the numbers in between the numbers that the user has input?

print perfect numbers from 1 to 100 in python
c program to print numbers in a given range
check perfect number from list in python
python program to check perfect number using while loop
perfect number program in python using while loop
c check if number is in range
perfect number in python using function
python program to find perfect number using function

I'm using Grok learning and I need help with finding the numbers in between if a user inputs them.

For example:


The numbers in between: 4, 5

But this is what I need exactly:

Up the lift 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.

Current floor: 3

Destination floor: 6

Level 3

Level 4

Level 5

Level 6 ​

Current floor: 1

Destination floor: 2

Level 1

Level 2

So my current code is:

current = int(input("Current floor: "))
desti = int(input("Destination floor: "))

Now I'm confused how to get it to output the numbers in between.

You could use the range() function using the upper and lower bounds entered by the user:

>>> current = int(input("Current floor: "))
>>> desti = int(input("Destination floor: "))
>>> print(*range(current+1, desti))
4 5
>>> between = list(range(current+1, desti))
>>> between
[4, 5]

If you want the floors going backwards you can do this:

list(range(desti, current, -1))

or you can simply reverse the range:

list(reversed(range(current+1, desti)))

Printing downwards:

print(*range(current+1, desti), sep='\n')

Formatting the output in a loop:

for level in range(current+1, desti):
    print('Level {}'.format(level))

C Program to Asks the User For a Number Between 1 to 9, and I need help with finding the numbers in between if a user inputs them. current = int(input("Current floor: ")) desti = int(input("Destination  Enter your number 45 User input is Number. Note: isdigit() function will work only for positive integer numbers. i.e., if you pass any float number, it will say it is a string. Let’s execute the above program again to validate it. Output two: Enter your number 22.40 User input is string. So it is better to use the first approach.

You could create a loop starting at the current floor (exclusive) and increment until you reach the destination floor (exclusive).

Python Program to find Perfect Number or Not, C Program to Asks the User For a Number Between 1 to 9 - C program which If the user inputs a number out of the specified range, the program should to Find the Greatest Number of Three Numbers; C Program to Asks the User For a Next Chapter : C Program to Check Whether the Given Number is Even or Odd ❯. Hey thanks for the reply. I don't think I was very clear in my original post. First, I am required to use a for loop for this and I'm trying to find the sum of the integers BETWEEN the two user input values. For example, if the user enters 6 and 10 I want to find the sum of the numbers 7+8+9.

Have a look at range function. I think this will do exactly what you want to do.

Lets say the range you need is in between 1 and 5.

In Python 2.x it returns a list,

>>> range(1, 5)
[1, 2, 3, 4]

In Python 3.x it's a iterator. so you should convert it to a list.

>>> list(range(1, 5))
[1, 2, 3, 4]

Second input is exclusive, so add one to the last value of the list


Python Program to Calculate Sum of Even Numbers, Some of the perfect numbers are 6, 28, 496, 8128 and 33550336 so on. Using this number it will calculate whether the user input is Perfect number or not Next, this Python program will find the Perfect Number between the Minimum and​  Given two numbers and as interval range, the task is to find the prime numbers in between this interval. Examples: Input : a = 1, b = 10 Output : 2, 3, 5, 7 Input : a = 10, b = 20 Output : 11, 13, 17, 19

basically you need to add a range for the # of level here was my answer

current = int(input("Current floor: "))
desti = int(input("Destination floor: "))
for i in range(current,desti):

Example Program 2, This Python program allows the user to enter the maximum limit value. Next, Python is going to calculate the sum of even numbers from 1 to that user-entered value. In this example, we are using Python For Loop to keep the number between 1 to Calculate Sum of Even Numbers from 1 to N maximum = int(input​(" Please  Calculate Average of Numbers in Python To calculate average ir arithmetic mean of numbers in python, you have to ask from user to enter some set of numbers say 5 numbers to find the average of those numbers as shown in the program given here.

Im doing the same thing on Grok Learning. Here is the answer:

destination = int(input("Destination floor: "))
number = current
while number <= destination:
  print("Level", number)
  number = number + 1```

Finding sum of digits of a number until sum becomes single digit , An example of how you could use a range check is shown below: number=int(​input("Please enter a number between 1  Hence 6 is a perfect number. Logic to find all Perfect number between 1 to n. Step by step descriptive logic to find Perfect numbers from 1 to n. Input upper limit from user to find Perfect numbers. Store it in a variable say end. Run a loop from 1 to end, increment 1 in each iteration. The loop structure should look like for(i=1; i<=end; i++).

Python Exercise: Calculate the sum and average of n integer numbers, Input : 1234 Output : 1 Explanation : The sum of 1+2+3+4 = 10, digSum(x) == 10 A brute force approach is to sum all the digits until sum < 10. total number of N digit numbers such that the difference between sum of even and odd digits is 1​  I'm a beginner in python, and I'm creating a program that asks the user for as many numbers as they want until they input "stop". Then the program would output how many numbers they entered and the result of all the numbers added together. Everything works well the first time, but as soon as I enter another number, the addition will be incorrect.

C++ Program to find the sum of n natural numbers, Python Conditional: Exercise - 42 with Solution. Write a Python program to calculate the sum and average of n integer numbers (input from the user). print(​"Input some integers to calculate their sum and average. show output (hide the code); Only show code or output (let users toggle between them). Write a Python program to find numbers between 100 and 400 (both included) where each digit of a number is an even number. The numbers obtained should be printed in a comma-separated sequence. There was a problem connecting to the server. Please check your connection and try running the trinket again. Run your code first!

How to write a Java program to input two numbers and find the sum , This program takes the value of n and finds the sum of first n natural numbers. To understand this program you should have the knowledge of C++ while loop. the input integer value into the variable n cin>>n; /* If user enters value of n as is Even or Odd · C++ Program to display Armstrong Numbers between 1 and  Python Program to Find Perfect Number between 1 to 1000. This Python Perfect number program allows the user to enter minimum and maximum values. Next, this Python program will find the Perfect Number between the Minimum and Maximum values.

  • Try the range() function.
  • Yes I have tried using the range function, but I'm still confused what to put in it. I'm sorry about that I'm new to python.
  • Google up some basic range() examples, give it your best shot, then add your attempt to your question if it doesn't work. Describe what you expected and what you actually got.
  • Alright I'll try that. Thank you :)
  • Thank you so much, it gave me an idea. I just need to create it into a list :) This was the outcome: Current floor: 1 Destination floor: 9 level 1 level [2, 3, 4, 5, 6, 7, 8] level 9
  • You are using Python 3 so, if you want it as a list, just call list(range(current+1, desti)).
  • How can I get the output to go downwards? not sideways?
  • Alright it works, thank you so much :) but sorry to bother you, is there a way to add 'level' infront of the numbers?
  • There's no need to make a list anywhere. Also, the range should go from current to desti+1, not current+1 to desti.
  • I'm sorry, but how exactly would I do that?
  • There's zero need to convert it to a list.
  • Thank you, this helped me a lot. But how do I create as a list going downwards?
  • You could use reverse function perhaps?…