+ 2

Python 3, need a solution for my code...

Thank you guys :)

31st Jan 2018, 6:46 PM
YOK
YOK - avatar
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
31st Jan 2018, 5:25 PM
🐙evil octopus
🐙evil octopus - avatar
+ 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)
31st Jan 2018, 4:32 PM
Paul
Paul - avatar
0
I changed my previous edit a bit. I hope it works now like you want it to.
31st Jan 2018, 5:43 PM
Paul
Paul - avatar
0
Great, thanks!
31st Jan 2018, 5:46 PM
YOK
YOK - avatar