0
duty free, coadcoach
numbers = input() numbers = [float(num) for num in numbers.split()] multiplied_numbers = [number * 1.1 for number in numbers] #for loop if statement for item in multiplied_numbers: if item > 20: print("Back to the store") break else: print("On to the terminal") break Every case is correct except the 3rd. What an I doing wrong?
2 Respostas
+ 3
Your code only checks the first item: Whenever the first item is > 20 or not, the loop stops after checking it.
0
You don't need to loop through it, you just need to check if the max exceeds 20. Looping through it does not guarantee that the first one is the highest anyway, plus it's the wrong thing to do.
max_price = max(multiplied_numbers)
if max_price > 20:
print("Back to the store")
else:
print("On to the terminal")