Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

TypeError: 'sage.rings.integer.Integer' object is not iterable

This is my code

m=[1,2,3,4]
c=[[1,3],[2,3],[1,2],[3,4]]

for i in Subsets(m):
    print(i)
    alpha_ij=0
    for j in c:
        delta_ij=set(i).symmetric_difference(set(j))
        print(delta_ij)

        for i in delta_ij:
            alpha_ij=alpha_ij+2^i
    print(alpha_ij)

When I compile it I get

{}
set([1, 3])
Traceback (most recent call last):        for j in c:
  File "", line 1, in <module>

  File "/tmp/tmpgaYE70/___code___.py", line 10, in <module>
    delta_ij=set(i).symmetric_difference(set(j))
TypeError: 'sage.rings.integer.Integer' object is not iterable

Which I do not understand because I do not think that I have iterated over any integer in any part of the code. The problem seem to be the last three lines because if delete them and compile the code there does not appear any error.