1
n = int(input("digite o número : ")
I=0
For i in lista:
lista[i].append(input("digite o número"
I+=1
else:
Print("lista cheia")
I’m new to Programming and I can’t implement what the questionnaire wants.
1
n = int(input("digite o número : ")
I=0
For i in lista:
lista[i].append(input("digite o número"
I+=1
else:
Print("lista cheia")
I’m new to Programming and I can’t implement what the questionnaire wants.
6
To get the highest value in a list of numbers, there is the native function max
:
numeros = [1, 2, 3, 4, 5]
print("Maior número da lista é:", max(numeros))
Returns the message:
Maior número da lista é: 5
To generate this list dynamically through the user input, in Python, the easiest is to use list comprehension:
numeros = [int(input("Número: ")) for i in range(20)]
The above line of code can be better matched with a similar but not analogous code snippet:
numeros = []
for i in range(20):
numeros.append(int(input("Número: ")))
The final code would be:
numeros = [int(input("Número: ")) for i in range(20)]
print("Maior número da lista é:", max(numeros))
See working on Repl.it.
0
We can resolve this issue in this way:
maior = max([x for x in input('Digite os valores: ').split()])
print(f'O maior número da lista é: {maior}')
When we executed this code we received the following message: Digite os valores:
. At this moment we must enter all values, in the same line, separated by a single space and press enter.
0
lista = []
while len(lista)+1 <= 20:
lista.append(int(input("Digite um número: ")))
print ("O maior valor é: ", max(lista))
0
x = 1
lista = []
print('Digite 20 números.')
while x <= 20:
n = int(input('Digite um número: [ %s ]: '%x))
lista.append(n)
x += 1
print('O maior valor é:',max(lista))
Please collaborate with the quality of community content by better elaborating your response. Very short answers will hardly be clear enough to add anything to the discussion. If your response is based on some function or feature of the language/tool, link to the official documentation or reliable material that supports your response. Searching for similar questions in the community can also be interesting to indicate other approaches to the problem.
Browser other questions tagged python python-3.x
You are not signed in. Login or sign up in order to post.
Please collaborate with the quality of community content by better elaborating your response. Very short answers will hardly be clear enough to add anything to the discussion. If your response is based on some function or feature of the language/tool, link to the official documentation or reliable material that supports your response. Searching for similar questions in the community can also be interesting to indicate other approaches to the problem.
– Woss