Nov-10-2017, 12:04 PM
(Nov-10-2017, 11:40 AM)DeaD_EyE Wrote: The methodinsert
oflst_binary
returnsNone
. Just memorize, that methods which mutates the object, returns regularlyNone
. Immutable objects return something, when you use a method. For examplestr.upper('Foo')
returns a new object, because the object itself is not mutable. It's immutable.
Methods of lists like sort, insert and remove won't return the list itself. The list object is mutating.
Just do your modification to your list withinsert
and usereturn ''.join(lst_binary)
to join the modified list.
Thanks for the reply. At last i thought about this way
return '1' + ''.join(lst_binary)
, and it works as well.