Syntax Error in the list

Asked

Viewed 51 times

1

I was doing the following exercise : "Make a program that reads 4 notes , show the notes and the media on the screen. "

My show went like this :

lista = [ ]

i =  0

soma = 0


while(i < 3):

      nota = int(input("Digite a nota do aluno:")    
      lista.append(nota)    
      i = i + 1
      soma = soma + nota

media = soma/4               


print("As notas foram:", lista)

print("A media foi:", media)

However, it is giving syntax error in the list (lista.append(nota)). Does anyone know why ?

  • 5

    Missed a close one ) in the previous row, referring to the function int.

  • 1

    What nonsense , thank you very much. Missed put i < 4 too.

  • The @Andersoncarloswoss explanation, got a little obscure, IMO, actually lacked parentheses in the int line itself, so... Change the line: nota = int(input("Digite a nota do aluno:") for nota = int(input("Digite a nota do aluno:"))

  • I switched and everything worked out. Thank you !

  • @user158657 , is less prone to error if you change this while i < 3 by a for i in range(4). See more in that reply

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.