count = 0
def test():
number = 3
while count < 6:
count = number + 3
test()
The above code generates the following error.
UnboundLocalError: local variable 'count' referenced before assignment
count = 0
def test():
number = 3
while count < 6:
print(count)
break
test()
But the code above runs well.
What is the difference between the two codes?