Discuss / Python / counter

counter

Topic source

90丶无悔

#1 Created at ... [Delete] [Delete and Lock User]
def create_counter():
  count = 0
  def counter():
    nonlocal count
    count += 1
    retern count
  return counter

count = create_counter()
print(count(),count())

  • 1

Reply