Is there a way to check if the type of a variable in python is string.. like
for integer values?
The correct way of solving this problem is:-
You can also solve this problem in the following way:-
if type(x) == str:
Another thing you can do is:-
var = 1 if type(var) == int: print('your variable is an integer')
var = 1
if type(var) == int:
print('your variable is an integer')
var2 = 'this is variable'if type(var2) == str: print('your variable is a string')else: print('your variable IS NOT a string')
var2 = 'this is variable'
if type(var2) == str:
print('your variable is a string')
print('your variable IS NOT a string')
I hope these answers will help you in clearing your doubts regarding this question.
Certification in Digital Marketing |
Certification in Big Data Analytics |
Certification in Cloud & Devops |
Certification in Full Stack Web Development
Big Data and Data Science Master’s Course |
Data Science Architect Master’s Program |
Cloud and DevOps Architect Master’s Course |
Artificial Intelligence Engineer Master’s Course |
Microsoft Azure Certification Master’s Training
Data Science Course Online |
Big Data Hadoop Certification Training |
Machine Learning Course Online |
Artificial Intelligence Course and Training |
Salesforce Certification Training: Administrator and App Builder |
Tableau Training and Certification Course |
Python Data Science Course & Training |
Ethical Hacking Course |
Business Analyst Course |
Courses in Cyber Security
© COPYRIGHT 2011-2021 INTELLIPAAT.COM. ALL RIGHTS RESERVED.
Download Salary Trends Now !
Learn how professionals like you got up to 100% Salary Hike.