Thomas
Thomas

Reputation: 69

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 running 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.

Upvotes: 1

Views: 636

Answers (2)

Gabe
Gabe

Reputation: 86718

<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(...).

Upvotes: 1

Sven Marnach
Sven Marnach

Reputation: 601699

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).

Upvotes: 4

Related Questions