In Python NameError: name ‘List’ is not defined. Did you mean: ‘list’? We face this error because we do type mistakes and type variable list (small letter l) as a List (capital letter L).
Please note python or any programming language is case-sensitive if you declare variables in small letters or capital letters then we need to use the same as we declare, For more clarification sees the below example.
Wrong Code
list = [ "a", "b", "c", "d", "e," ,"f", "g"]
print(List)
Error Massage
Traceback (most recent call last):
File "/home/kali/python/webproject/error/main.py", line 3, in <module>
print(List)
NameError: name 'List' is not defined. Did you mean: 'list'?
Wrong code line
print(List)
Correct code line
print(list)
- Wrong action: List (capital letter L)
- Correct action: list (small letter l)
- Convert LIst into a list.
Entire Correct Code line
list = [ "a", "b", "c", "d", "e," ,"f", "g"]
print(list)
What is NameError: name ‘List’ is not defined. Did you mean: ‘list’?
In Python, We face this error because we do type mistakes and type variable list (small letter l) as a List (capital letter L). Please note python or any programming language is case-sensitive.
How to fix NameError: name ‘List’ is not defined. Did you mean: ‘list’?
if you declare variables in a small letter list (small letter l) then we need to use the same as we declare a list (small letter l) not a List (capital letter L), For more clarification see the above example.
For more information Visit YouTube Channel.

