-1
I’m doing an exercise whose code is this::
import random
n1 = str(input ('Primeiro aluno:'))
n2 = str(input ('Segundo aluno:'))
n3 = str(input ('Terceiro aluno:'))
n4 = str(input ('Quarto aluno:'))
lista = [n1,n2,n3,n4]
escolhido = random.choice(Lista)
print('O aluno escolhido foi: {}'.format(escolhido))
in pycharm it runs normally but in vs code it gives the following error:
File "challenge019.py", line 2, in
n1 = str(input ('First student:')) File "", line 1, in Nameerror: name 'hi' is not defined
the hint is: learn to switch, not Ides. The code above has an error, the variable "list" appears with the name "List". The suggestion is to use a source editor, with an IDE, and run your programs in the terminal. When you have security, then you can use an IDE - which will help you instead of doing a lot of magic that takes you away from the main subject.
– jsbueno
in particular, if that mistake you posted, it wasn’t that code that was running. Go back there and see what the file looks like. There is no variable
oi
on line 2.– jsbueno
I would say that the error occurred because it is running the code in Python 2, using the function
input()
.– Woss
Actually I had made a change on line 7, where the variable 'list' was initially with 'L'. But what is not working, is that when I run the program the first variable receives only numbers, when I put a name, as in the above case was "hi" not right.
– Marcos Wesley
I’ll study some more and see what I’m missing, thanks for the tips guys!!
– Marcos Wesley