[Python] Python : why am I getting " nameError: name ' x ' is not defined? " [closed]

Discussão em 'Python' iniciado por Stack, Agosto 29, 2025.

  1. Stack

    Stack Membro Participativo

    I’m just starting to learn Python, and I got this error message:

    NameError: name 'y' is not defined

    Here’s my code:

    x = 5

    print(y)

    I expected it to print 5, but instead it shows the error.

    Can someone explain why this happens and how I should fix it?

    I tried assigning x = 5 and then printing it.

    I expected the program to print 5.

    But instead, I got an error: "NameError: name 'y' is not defined".

    Continue reading...

Compartilhe esta Página