Hey guys.

I'm having some trouble with this error.

class App():
	i = 0
	def updateCount(self):
		i = i +1
	
app = App()
app.updateCount()

input('Enter')

I have tried global i but get an error 'global name i is not defined'.

Can someone clue me in? Cheers :D

As you wrote your class, i is a static variable (a class member and not an instance member). You can update it with App.i += 1

commented: nice and helpful +15
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.