Question with deleted question / function definition problem

Asked 2 years ago, Updated 2 years ago, 17 views

I think it didn't fit the purpose of the bulletin board, so I'll look Thank you.

python

2022-09-21 11:14

1 Answers

Next time, don't just write that there's an error, but tell me the contents of the error message

I didn't turn the code, but I don't know where the error occurs, but first, I'll tell you what I see.

The append of the python list is roughly like this.

def append(self, x)
    self.a[len(self.a):] = [x]

At the end of the list, connect the value received by the parameter, but the important thing is that there is no return value

You can simply test it in the following ways:

>>> a = 1
>>> b = []
>>> c = b.append(a)
>>> b
[1]
>>> c
>>> 

A is normally appended for b, but c is NoneType because there is no return value for append.

Likewise, since the code you uploaded does not have a return value of close.append(a), nothing is stored in closing, so if you try to get sum or len at nothing, you will get an error.


2022-09-21 11:14

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.