0

I'm trying to make a function that adds 1 everytime when called. For example, the output of this code is would be 3, but it returns 1.

def count():
    count = 0
    count += 1
    return count

count()
count()
count()
print(count())
ShadowRanger
  • 124,179
  • 11
  • 158
  • 228
Mogur
  • 9
  • 3
  • You can do this either with a global variable or by creating a class and using a class variable. Is there anything you're writing this for, or just learning? – blackbrandt Nov 11 '21 at 15:04

0 Answers0