Python-programming-exercises icon indicating copy to clipboard operation
Python-programming-exercises copied to clipboard

Question 3, Level-1

Open suizhixie opened this issue 6 years ago • 5 comments

for i in range(1,n+1): NameError: name 'n' is not defined

suizhixie avatar Oct 17 '18 07:10 suizhixie

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

tiny-pangolin avatar Oct 20 '18 23:10 tiny-pangolin

Hi @suizhixie, You should revisit here. And also check to Python 3.x solutions, more question will be added soon.

ashwanidv100 avatar Oct 25 '18 13:10 ashwanidv100

defined n because you add value in n

amit-gadia avatar Feb 27 '20 11:02 amit-gadia

You have to be define it. It means that you have to tell your machine that from where n starts.

skvishnoipro avatar Feb 29 '20 20:02 skvishnoipro

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): print(i) 1 2 3 4 5 6 7 8 9 should help

shyamgupta196 avatar Jun 18 '20 16:06 shyamgupta196