Search code examples
pythonintegerdefault

Default initial value of an integer variable in Python?


What is the default initial value of an integer variable in Python?


Solution

  • Python doesn't allow you to reference an undefined variable, and trying to do so will raise a NameError. Often, when you create a variable that contains an integer, you will also assign some value to it.

    >>> x = 42