s = { }
t = {1, 4, 5, 2, 3}
print(type(s), type(t))
<class 'dict'> <class 'set'>
The first line initializes an empty dictionary s using curly braces {}, and the second line initializes a set t with the elements 1, 4, 5, 2, and 3 using curly braces as well.
The print(type(s), type(t)) statement then prints the types of s and t. When you run this code, the output will be:
<class 'dict'> <class 'set'>
This indicates that s is of type dict (dictionary) and t is of type set. If you want s to be an empty set, you should use the set() constructor:
s = set()
t = {1, 4, 5, 2, 3}
print(type(s), type(t))
With this corrected code, the output will be:
<class 'set'> <class 'set'>
Now both s and t will be of type set.
0 Comments:
Post a Comment