It's a question from Python about For Moon Implemented as follows
n = 10
for i in range(0, n-1):
// Now we understand that n is 9
for j in range(i + 1, n):
// So n here is going to be the 10 declared above
// I wonder if it will be 9 which is the n-1 value of the for statement above one level.
// It's 9 in code, but I don't understand why it's 9
print("i = ",i,"// j = ",j)
It's a very basic question, but I'm confused about various algorithms with this for doorcrying Please reply.
for
The variable n does not change in the code above.
range (0, n - 1)
is the same as range (0, 9)
.
In the second for, n is of course 10.
The range (0, 10) is expressed from 0 to 9.
© 2024 OneMinuteCode. All rights reserved.