Something Wrong With My Program's Function Python .extend()
while I was creating a function for a program in python, I encountered a problem. every time I run the program, after inputting what's needed I always get an Error saying: 'Attribu
Solution 1:
.extend
is in-place method, it does not return anything, it modifies your list.
see for example
>>> print [].extend([3])
None
or
>>>x = []>>>print x
[]
>>>y = x.extend([4])>>>print y
None
>>>print x
[4]
thus to solve the problem, simply change
OUT=(OUT.extend(IN))
to
OUT.extend(IN)
or to equivalent
OUT = OUT + IN
Post a Comment for "Something Wrong With My Program's Function Python .extend()"