Learning Python: Variables in Python
Introduction to blog series
This blog post will be part of a series of blog posts which I will be publishing regarding what I have been reviewing and learning in Python.
Variables in Python
Variables in Python can be declared either with a data type or without one. For example, if we want to declare a variable of type string, we would do the following:
message = str("Hello World")
We can also declare it without any declaration or type hinting of the data type and leave it up to the interpreter to figure it out as follows:
message = "Hello World"
Checking data type of variable
In the latter case if we want to find out the data type, we would do the following:
# is used to comment in Python
type(message) #<class, 'str'>
isinstance(message, str) #True
This blog post was originally published on my blog Communicode, where I write about different tech topics.