Traceback most recent call last File Dpythontextpy line 6 in module printsummTypeError builtin_function_or_method object is not subscriptable
The error message is indicating that you are trying to access an index of a built-in function or method, which is not possible because they are not subscriptable.
In this case, it seems like you are trying to access an index m of a function or method called sum. However, sum is a built-in function in Python that is used to calculate the sum of elements in an iterable. It cannot be subscripted like a list or a string.
To fix this error, you need to make sure that you are using the sum function correctly. If you are trying to calculate the sum of elements in a list, you should pass the list as an argument to the sum function, like this:
my_list = [1, 2, 3, 4, 5]
result = sum(my_list)
print(result)
If you are trying to access an element at index m in a list, make sure you have a list variable and use square brackets [] for indexing, like this:
my_list = [1, 2, 3, 4, 5]
m = 2
print(my_list[m])
Make sure you are not confusing the built-in sum function with a variable named sum that you might have defined earlier in your code.
原文地址: https://www.cveoy.top/t/topic/jcka 著作权归作者所有。请勿转载和采集!