I’ve reached that part of my Python lesson to learn that a variable can be defined and then re-assigned.
What reason would anyone have for doing this? Wouldn’t it keep the code less confusing to just keep things defined the way they were instead of changing them somewhere else down the line?
Here’s the example I have from the lesson:
# my_int is set to 7 below. What do you think # will happen if we reset it to 3 and print the result? my_int = 7 # Change the value of my_int to 3 on line 8! my_int = 3 # Here's some code that will print my_int to the console: # The print keyword will be covered in detail soon! print my_int