Всем привет.
def thing(state):
a,b,time=state
first, torch = b
print(first,torch)
s = set()
for item in a:
s = s | {item}
return {(frozenset(s | {first, torch}), frozenset([]), time + first): (first, first, 'reverse')}
print(thing((frozenset([1]), frozenset([2, 'lamp']), 5)))
результат 1
2 lamp
{(frozenset({1, 2, 'lamp'}), frozenset(), 7): (2, 2, 'reverse')}
результат 2
lamp 2
Traceback (most recent call last):
File "/PycharmProjects/First_proj./Test.py", line 59, in <module>
print(thing((frozenset([1]), frozenset([2, 'lamp']), 5)))
File "/PycharmProjects/First_proj./Test.py", line 57, in thing
return {(frozenset(s | {first, torch}), frozenset([]), time + first): (first, first, 'reverse')}
TypeError: unsupported operand type(s) for +: 'int' and 'str'
Process finished with exit code 1
Как это исправляется?