type()
noun
say it: “TYP” /taɪp/
A built-in Python function that tells you the data type of a value, such as int for 42 or str for "hello".
What does type() do?
type() tells you the data type of a value. Handy when something isn't behaving the way you expect.
print(type(42)) # <class 'int'>
print(type("hello")) # <class 'str'>
In a sentence
- “print(type(3.5)) shows <class 'float'>.”
- “type() showed that the "number" from input() was really a str.”
Level: Novice · More Python terms at this level
Updated