+ 1
Test 3 failed
n = input().split(" ") euro = [float(x) for x in n] total = 0 for x in euro: x *= 1.1 if x > 20: print('Back to the store') break else: print('On to the terminal') break
5 odpowiedzi
+ 2
Hi, the solution to this code could be something like this:
n = input().split(" ")
euro = [float(x) for x in n]
max_payment_usd = max(euro) * 1.1
if max_payment_usd < 20:
print('On to the terminal')
else:
print('Back to the store')
No need to loop yourself. Python has a handy max() function that finds the highest element in the list, which is the only number that you need to check.
Your code probably doesn't work because it breaks out of the loop after checking the first element, regardless of what number it is. This is because you use the 'break' keyword in the 'else' block, which effectively means 'break out of the loop no matter what in the first iteration'.
+ 1
Thanks a lot.
0
Anyone knows whats wrong with my code? Please help
0
My guess is that the problem is that you're breaking out of the loop immediately after processing the first element. But I'm not sure since you haven't said what the expected output is.
0
Its the code challenge "Duty Free" . So my if statements should be outside the loop? Sorry im new to coding hope that you could enlighten me