Question on updating the variables

I have updated the variable, but the outcome doesn’t change. The two outcomes are both 96.
But if I code the command ‘quilt_squares = quilt_width * quilt_length’ below again, the outcome will be 64 which is what I want. I don’t know why. I am confused :face_with_spiral_eyes:, Could someone tell me the reason :smiling_face: Thank you very much! :kissing_heart:

quilt_width = 8 quilt_length = 12 quilt_squares = quilt_width * quilt_length print(quilt_squares) quilt_length = 8 print(quilt_squares)

You declare quilt_squares as a variable and update it on line 3. It is never updated again and will print the same for both print statements. Not sure of the python syntax, but you need to make quilt_squares a function,

quilt_width = 8
quilt_length = 12
def quilt_squares(wid, len): return wid*len
print(quilt_squares(quilt_width, quilt_length))
quilt_length = 8
print(quilt_squares(quilt_width, quilt_length))
1 Like

Thank you very much! :smiling_face: You help me a lot :smiling_face: