Question:
I wrote this code and its suppose to give me the highest number but its printing out three number
numbers = [312, 1434, 68764, 4627, 84, 470, 9047, 98463, 389, 2]
high = numbers[0]
for number in numbers:
if number > high:
high = number
print(f" The highest number is {high}")
Basically it’s printing out a number every time it finds a number higher than the current highest number. So just move the print statement out of the loop like so:
numbers = [312, 1434, 68764, 4627, 84, 470, 9047, 98463, 389, 2]
high = numbers[0]
for number in numbers:
if number > high:
high = number
print(f" The highest number is {high}")