Hi, really basic question about "You've been Reassigned"


#1

I just want to know why it is that I have to enter in “
my_int = 3” twice, rather than just once sufficing. What is the purpose of this?

Why does once not suffice?



# 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 = 3

# Change the value of my_int to 3 on line 8!


#2

Hi @devjumper12520,

The intent was for you to leave the original statement as is …

my_int = 7

… and to write these new statements …

my_int = 3
print my_int

The purpose of the exercise is to demonstrate that a program can include statements that change the values of variables as the program executes.

Within this short program it is not really obvious how this can be useful, but the technique of reassignment will come in handy in later exercises.


#3

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.