Reputation: 215
I have written the following code
p1=1
p2=2
p3=set(p1).union(set(p2))
p3
In this case I would have expected for p3 to be equal to {1,2}, but when trying to run the program, I obtain:
'int' object is not iterable
How may I fix this?
Is there also a way to print the answer as an ordered pair? such as (1,2) in this case.
I have changed the code a little, because this is what I would like to fix, since having this step solved, will let me know how I do the rest.
Thanks in advance
Upvotes: 0
Views: 167
Reputation: 215
I saw what my mistake was. what I needed was a pair of [].
The correct code is:
p1=1
p2=2
p3=set([p1]).union(set([p2]))
p3
Upvotes: 0