[Tutor] The Python way and two dimensional lists
Dennis Lee Bieber
wlfraed at ix.netcom.com
Sun Nov 21 21:15:01 EST 2021
On Mon, 22 Nov 2021 11:13:15 +1100, Phil <phillor9 at gmail.com> declaimed the
following:
>
>for s in set_list:
> for r in col[0]: # instead of row:
> if s.issubset(r):
> pairs[tuple(sorted(s))] += 1
>
>Traceback (most recent call last):
> File "/usr/lib/python3.9/idlelib/run.py", line 559, in runcode
> exec(code, self.locals)
> File "/home/phil/Python/set_count2.py", line 75, in <module>
> if s.issubset(r):
>TypeError: 'int' object is not iterable
Have you looked at the definition of .issubset()?
The object one applies it to must be a set. The parameter passed must
be a superset (or equal). It returns true if the object -- in your example,
that would be s -- is a subset of the parameter r .
But your r is not a set -- "for r in col[0]" is selecting the first
element of whatever col contains, which appears to be a single integer at
this point. I suspect you need to: 1) ensure that "r" is a SET, and
possible 2) reverse the call r.issubset(s)
--
Wulfraed Dennis Lee Bieber AF6VN
wlfraed at ix.netcom.com http://wlfraed.microdiversity.freeddns.org/
More information about the Tutor
mailing list