I am receiving a TypeError: ‘str’ object is not callable when I write my code - hand-typed but copies, but when I copy/past the answer provided, I have the correct answer? I just do not see the differences, and am hoping someone could briefly point out why I’m erroring?
My Code:
a_list = [1, 8, 10, 9, 7]
print(max(a_list))
def max(a_list):
return 'No max value returned'
max_val_test_0=max(a_list)
print(max_val_test_0)
del max
Output
TypeErrorTraceback (most recent call last)
<ipython-input-1-fb0dc62600a0> in <module>()
1 a_list = [1, 8, 10, 9, 7]
----> 2 print(max(a_list))
3 def max(a_list):
4 return 'No max value returned'
5
TypeError: 'str' object is not callable
Dataquest Answer and Code
a_list = [1, 8, 10, 9, 7]
print(max(a_list))
def max(a_list):
return "No max value returned"
max_val_test_0 = max(a_list)
print(max_val_test_0)
del max
Output
No max value returned