0d: 00h: 00m: 00s

🎁 Get 3 extra months of learning β€” completely FREE

That's 90 extra days to master new skills, build more projects, and land your dream job.

Become a PRO
Background Image

🎁 Get 3 extra months of learning completely FREE

Become a PRO
Rashina nilofar Rashina
2 months ago
Rashinacountry asked

How can I write a Python program to check whether a value is a string or not?

Sarthak Baral
Expert
yesterday
Sarthak Baral answered

Hi Rashina,

In Python, you can check this using isinstance():

value = "Hello"

if isinstance(value, str):
    print("It is a string")
else:
    print("It is not a string")

Just replace value with the variable you want to test.

If you have more questions, I am here to help 😊

Python
This question was asked as part of the Number Guessing Game course.