Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Why does assignment to int and float are not generating error whereas assignment to while does generate error?

Source:

int = 33

float = 0.0

while = 33

Output:

while = 33
          ^
SyntaxError: invalid syntax

Why does assignment to int and float are not generating error in python whereas assignment to while generates error?

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

while is a keyword. Keywords are essential parts of the language that cannot be used as variable names.

int and float are built-in types. That means they already essentially are variable names, but they are automatically assigned to standard parts of the library for you to use. However, that does not prevent you setting them to something else.

NB Though you can do it, it is generally inadvisable to set the names of built-ins to something else, because it leads to unclear code and confusing bugs.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading