Skip to content
Advertisement

NameError: name ‘true’ is not defined [closed]

I want to use Boolean ( true / false ) in my python source file, but after running the application, I receive the following error:

JavaScript

The error lies on while true:, when I am trying to make the Raspberry Pi run a HTML script when it receives input on port 17:

JavaScript

Advertisement

Answer

Python’s boolean constants are capitalized: True and False with upper case T and F respectively.

The lower-case variants are just valid free names for variables, so you could use them for whatever you want, e.g. true = False (not recommended ;P).

User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement