×

Python Tutorial

Python Basics

Python I/O

Python Operators

Python Conditions & Controls

Python Functions

Python Strings

Python Modules

Python Lists

Python OOPs

Python Arrays

Python Dictionary

Python Sets

Python Tuples

Python Exception Handling

Python NumPy

Python Pandas

Python File Handling

Python WebSocket

Python GUI Programming

Python Image Processing

Python Miscellaneous

Python Practice

Python Programs

Python | Declare any variable without assigning any value

Here, we will learn how to declare any variable without assigning any value in Python? By IncludeHelp Last updated : April 13, 2023

Declare any variable without assigning any value

Since, Python is a dynamic programming language so there is no need to declare such type of variable, it automatically declares when first time value assign in it.

Still, this is a common question asked by many programmers that can we declare any variable without any value?

The answer is: "Yes! We can declare such type of variable". To declare a variable without any variable, just assign None.

Syntax

variable_name = None

The following code shows the declaration of variable assigned with None:

num = None

Let's understand through a program.

Example to declare any variable without assigning any value in Python

# Python program to declare a
# variable without assigning any value

# declare variable
num = None

# print the value
print("value of num: ", num)

# checking variable
if num == None:
    print("Nothing")
else:
    print("Something")

# assign some value
num = 100

# print the value
print("value of num: ", num)

# checking variable
if num == None:
    print("Nothing")
else:
    print("Something")

Output

value of num:  None
Nothing
value of num:  100
Something

Python Basic Programs »

Advertisement
Advertisement

Related Programs

Comments and Discussions!

Load comments ↻


Advertisement
Advertisement
Advertisement

Copyright © 2025 www.includehelp.com. All rights reserved.