This is a sample code I looked up. I am a rookie and I do not really understand it.
n = int(input('Enter an interger >= 0:'))
fact = 1
for i in range(2,n+1):
fact = fact*i
print(str(n)+' factorial is '+ str(fact))
My biggest problems are:
1) for i in range(2,n+1) how do read this? I looked up the doc and it said "assigned object to target. I can identify range is the object, and i is the target. But can anyone be more specific? is 2 the start, and n+1 the increment? I come from Matlab but I have problem with this.
May someone comment on that line, in a plain word? Thank you
2) I want to restrict the limit here. I want to set range i = 1,10, because my ideal program (in a while loop is):
while 1<= n
How do I restrict i in that for loop above?