Solution:
Well, before anything else you need to know about the built-in names and functions in python. So, in python, the python interpreter has already assigned a pre-defined value to a built-in function or name.
Now, coming to the second part. Why you are getting this error message? When you have given a certain value in a list it lost the pre-define value of it and re-assigned with the new value. Hence you overwrite the pre-defined value of the list, you can not use it’s earlier value again. Thus the error message is raising up by the interpreter. So, how can you fix this? Either delete the re-assigned value of the list or rename the variable from list to something else like this:
mylist = [1, 2, 3]
myrange = list(range(1, 10))
for num in mylist:
if num in myrange:
print(num, 'is between 1 and 10')
I believe I solved the problem. Please leave a kudos for me. Thanks.