Ask coding questions

← Back to all posts
While loops
sharkquik (0)

Simple program to input 2 integers and display in ascending order.

I want to check

  • first integer can be greater, equal or less than second integer
  • display will still be ascending order
Answered by Geocube101 (663) [earned 5 cycles]
View Answer
Comments
hotnewtop
Geocube101 (663)

If you must use while loops then let me know

sharkquik (0)

@Geocube101 Hi thanks for getting back. Yes i'll need to use while loops for this. And when i input the 2 integers, it has to display in ascending order, Example 1,
input 1: 3
input 2: 5
output:
3
4
5
Example 2:
input 1: 5
input 2: 3
output:
3
4
5

Geocube101 (663)

@sharkquik I see

Method 1


Method 2

sharkquik (0)

@Geocube101 Hi thank you so much! Yes method 2 works. Thanks for your help.

creepershan (4)

def consec3():

consec3()

this gets rid of the smaller value going one above the larger one, there's definitely a more simple way to do this but it works :P

sharkquik (0)

@creepershan Hi there thanks for your help! Yeah i'm looking for the easiest way because at this stage i haven't learn about the list function yet. I'm new in python =) Thanks for your input.