+ 2
Python 3, need a solution for my code...
Thank you guys :)
4 Réponses
+ 4
this also does the trick:
nums, i = [], 0
while True:
x = int(input())
if not x: break
nums.append(x)
if i: print('same' if nums[i]==nums[i-1] else ('up' if nums[i]>nums[i-1] else 'down'))
i+=1
+ 3
Try it like this:
m = 0
a = ""
print("Enter the first number: " , end = "")
x = input()
num1 = int(x)
m = num1
finished = False
while not finished:
print('Enter the next number (0 to finish): ', end = '')
s = input()
num = int(s)
if num != 0:
if num == m:
m = int(num)
# a = "Same "
a += "Same "
elif num < m:
m = int(num)
# b = "Down "
a += "Down "
elif num > m:
m = int(num)
# c = "Up "
a += "Up "
else:
finished = True
print(a)
0
I changed my previous edit a bit. I hope it works now like you want it to.
0
Great, thanks!