I can do
>>> s = {1}
>>> type(s)
<class 'set'>
but
>>> s = set(1)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: 'int' object is not iterable
What is the difference?
", line 1, in I can do but What is the difference? Copyright © 2021 Jogjafile Inc.
Why does building a set fail when using set(int)?
210 Views
Asked by
Finn
At
>>> s = {1}
>>> type(s)
<class 'set'>
>>> s = set(1)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: 'int' object is not iterable
There are 1 best solutions below
Related Questions in PYTHON
Related Questions in SET
Related Questions in ITERABLE
Trending Questions
Popular Questions
The difference is that the
set()constructor takes an iterable. A single number is not an iterable.