For your hobbies/ for loop question


#1



https://www.codecademy.com/courses/python-beginner-en-cxMGf/1/2?curriculum_id=4f89dab3d788890003000096#

those two functions yield the same result so are x and hobby the same? x in the first function and hobby in the second function should be 0,1, 2 so how does the second function recognize that hobby and hobby are different?


hobbies = []

for x in range(3):
    hobby = str(raw_input("What are your hobbies?: "))
    hobbies.append(hobby)

print hobbies

hobbies = []

for hobby in range(3):
    hobby = str(raw_input("What are your hobbies?: "))
    hobbies.append(hobby)

print hobbies

#2

@jaelee45,
For an explanation read
https://docs.python.org/2/reference/executionmodel.html


#3

hobbies=[]
for hobby in range(3):
hobby=raw_input("Input a hobby: ")
hobbies.append(hobby)

"this is the answer"