Skip to content
← Back to Community
for x in range(start, stop)
Profile icon
smuchallil

Hi all,
She showed in her video the stop is the number-1 which I think should be just number(without -1), since in range the stop value is excluded.

could someone tell me why she has to put -1 to the stop value-

Thanks

Voters
Profile icon
4B11LUN
Profile icon
smuchallil
Comments
hotnewtop
Profile icon
Coder100

She want's to exclude the last value I think.

Profile icon
smuchallil

@Coder100
That's why I mean, if we want to exclude the number, we do not have to do number-1 because in range(star, stop) stop will always be excluded right.
afterall I checked her solution, it is only range(2, number) but in her video solution she wrote range(2, number -1)

Profile icon
RYANTADIPARTHI

Uh, could you explain your question better?

Profile icon
smuchallil

@RYANTADIPARTHI
if you see her video, she tried to find the prime number using this code for x in range(2, number - 1) which in my opinion she could remove the -1 because the range command will excluded the number.
Then, I check her solution, she only dis range(2,number), so the video and the solution are different.

Profile icon
RYANTADIPARTHI

@smuchallil yes. The -1 is to exclude the number. To stop it as soon as it reached that point.