EN
Python - how to check object / variable type?
1 answers
0 points
How can I check object / variable type in Python?
1 answer
0 points
You can use the type()
function.
Practical example:
xxxxxxxxxx
1
my_string = 'abc'
2
my_int = 123
3
my_bool = True
4
my_list = [4, 5, 6]
5
my_dict = {'a': 1, 'b': 2, 'c': 3}
6
7
print(type(my_string)) # <class 'str'>
8
print(type(my_int)) # <class 'int'>
9
print(type(my_bool)) # <class 'bool'>
10
print(type(my_list)) # <class 'list'>
11
print(type(my_dict)) # <class 'dict'>
0 commentsShow commentsAdd comment