Int is not a keyword in python, and hence can be used as a variable name. I tried to assign a string into the name and it worked.
I did this in the IDLE of Python3.8.2
>>> a = int(4.5)
>>> print(a)
4
>>> int = 'abc'
>>> print(int)
abc
>>> b = int(5.7)
Traceback (most recent call last):
File "<pyshell#4>", line 1, in <module>
b = int(5.7)
TypeError: 'str' object is not callable
>>> print(b)
the code works without the last part. ie from b = int(5.7)
Why does it happen? and shouldn't int be a keyword? how can we fix it keeping the existing code intact as if working in the console?
I tried using the del keyword and it worked. but I don't know why.
>>> del int
>>> b = int(5.7)
>>> print(b)
5
This works.
Please explain. :)