0
Hi, I have python as one of my second semester classes and I need a little help. I have an exercise where I can’t make it work properly; here is the statement:"Write a program that reads a set of numbers from the keyboard until the user enters a negative number. In final you must print the largest of these numbers." The following code was what I did but as I said above, it doesn’t work properly.
def read():
list=[]
n = int(input("Introduza um nº negativo para terminar:"))
while True:
if n > 0:
n = int(input("Introduza um nº negativo para terminar:"))
list.append(n)
else:
break
print("O maior nº é:"+max(list))
read()
I thank you for your help.
– Junior