Discuss / Python / 作业

作业

Topic source

B O O M!

#1 Created at ... [Delete] [Delete and Lock User]

def createCounter():

    x = []

    def counter():

        x.append(1)

        return sum(x)

    return counter

def createCounter2():

    x = 0

    def counter():

        nonlocal x

         x += 1

        return x

    return counter


  • 1

Reply