Lesson 4


#1

Isn't this "my_int" redefined?


#2

Yes, it is. :slightly_smiling:

The programme runs from above, down the lines one by one:

first you define my_int as 7:

my_int = 7

then you change it on line 8 to 3:

my_int = 3

which makes my_int 3 in the end, because it didn't change after that.


#3

what is the question? my_int was 7 (line 4), then you changed it to 3 (line 8), then it prints 3 (line 13), so your variable is redefined


#4

Indeed. The interpreter reads just like you'd read a book!

That is, if you're American :wink:

You'll learn later that you can override variables to give them new values..


Here is an example of this in action:

# declaring the variable "dog_name" and assinging it a value for the first time
dog_name = "Moe"

# this is where you will override the "dog_name" variable with a  new value
dog_name = "Frank"

Hope this helps! :slightly_smiling:


#5

He's just confirming that, as is it, the my_int variable is indeed being redefined! :wink:


#6

Thank you all guys ! I was confused before cause this way I tried in C++ couldn't work.


#7

you use int to declare a integer, if you want to overwrite you should just do:

a = 8;

no need to use int


#8

I see. Thanks a lot.:relaxed:


#9

This post was flagged by the community and is temporarily hidden.