Doubt about the Vscode

Asked

Viewed 69 times

-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

  • 7

    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.

  • 2

    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.

  • 1

    I would say that the error occurred because it is running the code in Python 2, using the function input().

  • 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.

  • I’ll study some more and see what I’m missing, thanks for the tips guys!!

1 answer

0


Mark Wesley, the error you reported is not about the code described above. The error would be another, since line seven should start with l minuscule. After fixing this, in the case of your code, as it requires a prompt to answer the questions of "input", you must execute the debug using python with integrated terminal, in this way the vscode opens a screen to access the terminal, where you will answer the questions getting the expected result.

Browser other questions tagged

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