I have a function when I use it outside the class as a function it works perfectly but when I want to use I as a method in a class I get a TypeError massage :
Traceback (most recent call last):
File "H:\python\prototyp_01.py", line 122, in <module>
manupacians.koor(z)
File "H:\python\prototyp_01.py", line 58, in koor
if manupacians.ordna(z)== z:
File "H:\python\prototyp_01.py", line 45, in ordna
new_j = j-1
TypeError: unsupported operand type(s) for -: 'list' and 'int'
My function

def ordna(self,x):
        b = 0
        y = []
        for j in x:
            new_j = j-1
            if new_j<0:
                del new_j
            else:
                y.append(new_j)
                b+=1
        y.append (b)
        y.sort()
        y.reverse ()
        return y

Any suggestions? Thanks

Looks like x is a list of lists.

list of lists??

Ya true, x must be of the format [[1,2,3],[4,5,6],[7,8,9]]
so when the first entry is called
new_j = j-1
it would be something like [1,2,3] -1
so it shows an TypeError
Check what x is returning

Thank you very much I will check it!

yes it was a list and a tupel lookslike this.

[4, 4, 2] 10
([4, 4, 2], 10)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.