How to Define a Null Variable in Python
Updated onbyAlan Morel
Table of Contents
In programming, variables are used to store values of different types.
There is, however, a type that is special in that it is used to store nothing.
That value is called null.
In this post, we'll learn how to define a null variable in Python.
How to define a null variable
As mentioned before, null is a type used to mean nothing, or no value.
You can use this to define a variable without actually giving it a value.
Let's see how this is done in Python.
PYTHONvariable = None
print(variable)
BASHNone
This is useful for when you want to refer to a variable that has not been assigned a value yet, or to create a variable and then assign it a value later.
Conclusion
In this post, we learned how to define a variable in Python and assign it a null value.
Simply set the value of a variable to None
to define a null variable.
Thanks for reading!
Leave us a message!
×
- How to Install Node on Windows, macOS and Linux
- Getting Started with Express
- How to Serve Static Files with Nginx and Docker
- How to deploy a .NET app using Docker
- Getting Started with Deno
- How to deploy an Express app using Docker
- Learn how to use v-model with a custom Vue component
- Getting Started with Handlebars.js
- Build a Real-Time Chat App with Node, Express, and Socket.io
- Getting User Location using JavaScript's Geolocation API
- Learn how to build a Slack Bot using Node.js
- Getting Started with React