Python interpeter that randomly changes type or varrible
So I am learning python for fun and I have come across an error that completely stumps me. When I am run开发者_JAVA百科ning my code I get the following error:
TypeError: unsupported operand type(s) for /: 'int' and 'type'
this error is triggered by the division in:
for i in items:
print i[1]
multiplier = WeightLeft / i[1]
the thing that has me so confused is that when i print i[1] it prints
<type 'int>
I tried to force the denominator to be an int by putting int(i[1]) as the denominator but i get a new error:
TypeError: descriptor '__trunc__' of 'int' object needs an argument
Any advice someone could give would be greatly appreciated.
i[1]
is the type object int
, not an instance of this type. Trying to convert this type object to an integer is like calling int(int)
.
<type 'int'>
is what you'd get if you do i[1] = int
, so I'm guessing that somewhere you have i[1] = int
instead of i[1] = int(...)
.
精彩评论