Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Back to loops question
#1
Hi guys,

I want to write a program which takes a series of numbers finishing the process with 0. The program results should be as follow:

Enter the first number: 3
Enter the next number: 5
Enter the next number: 4
Enter the next number: 4
Enter the next number: 6
Up Down Same Up

However, I don't know how to write the code which produces the above result (Up Down Same Up) at the end.

Could anyone help me with this question please?

The following is my current code:

print("Enter the first number: ", end='')
s=input()
number1=int(s)
finished=False
while not finished:
   print("Enter the next number: ", end='')
   a=input()
   number2=int(a)
   if number2!=0:
       if number1>number2:
           print("Down")
       if number1==number2:
           print("Same")
       if number1<number2:
           print("Up")
       number1=number2
   else:
       finished=True
Reply


Messages In This Thread
Back to loops question - by wernerwendy - Jun-17-2017, 09:40 PM
RE: Back to loops question - by ichabod801 - Jun-17-2017, 10:02 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Old brain - New Language - Question on loops sailingbikeruk 6 5,595 Oct-03-2018, 08:27 PM
Last Post: nilamo
  Question on runtime and improving nested for loops ackmondual 1 3,757 Jun-13-2017, 11:11 PM
Last Post: ichabod801

Forum Jump:

User Panel Messages

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