For loop with num


#1

for num in range(3):
hobby = raw_input("Tell me one of your favorite hobbies: ")
hobbies.append(hobby)

In this for loop, why it will be okay to run without setting a variable called num and add ‘num += 1’ at the end?


#2

num is defined when you “declare” the for loop. range() will produce a list ([0, 1, 2]) and loop over all the values from this list, then exit when end of list is reached