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:
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:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
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 |