Why we can't define for as a variable in Python? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Why we can't define for as a variable in Python?

22nd Jul 2020, 3:48 PM
Deepak Sanjaykumar More
Deepak Sanjaykumar More - avatar
8 Answers
+ 9
instead of "for" you can use "for_" if you like that.
22nd Jul 2020, 4:02 PM
Lothar
Lothar - avatar
+ 7
Deepak Sanjaykumar More , if, else, for, while are keywords in python, not functions. You can get a list of them by just using: help('keywords')
22nd Jul 2020, 4:07 PM
Lothar
Lothar - avatar
+ 4
Deepak Sanjaykumar More , Keywords Keywords in a programming language are special reserved words that have specific meanings and purposes and can’t be used for anything else. This means that they can't be used as variable names, function or method names or class names.
23rd Jul 2020, 9:30 AM
Lothar
Lothar - avatar
+ 1
Continue going to the python course and you will see what these are
22nd Jul 2020, 4:01 PM
Andrei I
Andrei I - avatar
+ 1
Lothar help("keywords") works. But what are keywords? Explain please.
22nd Jul 2020, 4:11 PM
Deepak Sanjaykumar More
Deepak Sanjaykumar More - avatar
+ 1
Keywords are language statements and are reserved for this.
22nd Jul 2020, 4:55 PM
JaScript
JaScript - avatar
0
You can't use names that already have a meaning in python such as if, else, while, def etc
22nd Jul 2020, 3:55 PM
Andrei I
Andrei I - avatar
0
Are if, else, for, while functions? codemonkey Andrei I
22nd Jul 2020, 3:57 PM
Deepak Sanjaykumar More
Deepak Sanjaykumar More - avatar