Python-programming-exercises
Python-programming-exercises copied to clipboard
Question 3, Level-1
for i in range(1,n+1): NameError: name 'n' is not defined
you need to initialize n to some value ex
n = 1
for i in range(1,n+1):
you should add an if check if it is user input to make sure n is positive
Hi @suizhixie, You should revisit here. And also check to Python 3.x solutions, more question will be added soon.
defined n because you add value in n
You have to be define it. It means that you have to tell your machine that from where n starts.
it will give an error since you havent declared n you can do something like
n='any_thing'
for i in range(1,len(n)+1):