Skip to content

Python instanceof string | Example code

  • by

Use the isinstance() method to check whether the given variable is an instanceof string or not in Python.

Syntax if the type is a string

isinstance(s, str)

Python instanceof string example

Simple example code is instance string or not in Python.

x = 100
s = "Hello"

print(isinstance(x, str))
print(isinstance(s, str))

Output:

Python instanceof string

Do comment if you have any doubts or suggestions on this Python string topic.

Note: IDE: PyCharm 2021.3.3 (Community Edition)

Windows 10

Python 3.10.1

All Python Examples are in Python 3, so Maybe its different from python 2 or upgraded versions.

Leave a Reply

Discover more from Tutorial

Subscribe now to keep reading and get access to the full archive.

Continue reading