+ 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

14th Aug 2023, 4:48 PM
Angelmar Dayangco
Angelmar Dayangco - avatar
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'.
14th Aug 2023, 8:25 PM
Marcos Chamosa Rodríguez
Marcos Chamosa Rodríguez - avatar
+ 1
Thanks a lot.
15th Aug 2023, 9:30 AM
Angelmar Dayangco
Angelmar Dayangco - avatar
0
Anyone knows whats wrong with my code? Please help
14th Aug 2023, 4:50 PM
Angelmar Dayangco
Angelmar Dayangco - avatar
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.
14th Aug 2023, 5:04 PM
Marcos Chamosa Rodríguez
Marcos Chamosa Rodríguez - avatar
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
14th Aug 2023, 6:53 PM
Angelmar Dayangco
Angelmar Dayangco - avatar