Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialdevi prasad sahoo
213 Pointsinput a no which should check which data type is it
input a no or decimal which should check which data type is it
devi prasad sahoo
213 Pointshow to write a python program which should check which data type after giving a input
2 Answers
Iain Simmons
Treehouse Moderator 32,305 PointsTo get a Python object's type you can use the type() function. It will return a type object. If you want to check that it equals a particular type, you can do something like this:
a_string = "A String"
type(a_string).__name__ == 'str' # returns True in this case
For a list of the types that you could check for, see the Python Documentation's page on Built-in Types
devi prasad sahoo
213 Pointsthanks
Iain Simmons
Treehouse Moderator 32,305 PointsIf that answered your question, you should mark my answer as 'Best Answer', so others know that this question has been solved/answered.
Iain Simmons
Treehouse Moderator 32,305 PointsIain Simmons
Treehouse Moderator 32,305 PointsSorry, I'm not entirely sure what your question is. Can you please try and rephrase it?