Why can't it distinguish between intiger and float?


#1

<PLEASE USE THE FOLLOWING TEMPLATE TO HELP YOU CREATE A GREAT POST!>

<Below this line, add a link to the EXACT exercise that you are stuck at.>

<In what way does your code behave incorrectly? Include ALL error messages.>

<What do you expect to happen instead?>
I thought it would be an error

```python

my_int=1.23

my_int=3.13

print my_int

Output=3.13 (not and intiger though!)

<do not remove the three backticks above>

#2

why would it be an an error? Python is a dynamic typed programming language. It automatically assign the correct data type to the variable, that the name of your variable doesn’t match what it actually holds is task of the developer, of course we can write code to verify my_int will hold an integer


#3

Python does not check to make sure that the meaning of a name that you choose for a variable is consistent with the type of object you assign to that variable. That would require a cumbersome set of rules. However, it is best to choose names for variables that reflect, in some manner, their purpose. That makes the code more understandable to programmers who are reading it.


#4

haha okay. At least there is a chance for us to trick python! :slight_smile: Thanks for clarifying. I really appreciate it.


#5

Well, you are tricking other developers more then python, other developers looking at your code would assume the variable contains an integer value (because they deduce this from the variable name)


#9