0
count = 0

def lol(count):
    x = count + 1
    print(x)

Currently i am calling this function within another file in my python program, and count is = 1 everytime it is ran, im unsure why, im trying to make it +1 after every time it is ran.

Any help would be greatly appriciated.

1
  • It will always just print count+1 because that what the code does. In fact the above code won't do anything because you never call lol() Commented Dec 11, 2020 at 17:31

1 Answer 1

1

You are never modifying count, and only printing the result of x = 0 + 1

This would do what you want, however, you should re-consider your need for global variables

count = 0

def lol():
    global count
    count += 1
    print(count)
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.