Back
I'm trying to execute the following Python code:
def monotonic(a): n = len(a) for i in range(n): if((a[i]<a[i+1]) or (a[i]>a[1+1])): return truea = [6, 5, 4, 3, 2]print(monotonic(a))
def monotonic(a):
n = len(a)
for i in range(n):
if((a[i]<a[i+1]) or (a[i]>a[1+1])):
return true
a = [6, 5, 4, 3, 2]
print(monotonic(a))
And I get the following error:
NameError: global name 'true' is not defined
In python boolean values start with a capital letter so you need to return True instead of true.
If you want to get a deeper understanding of python you can watch this youtube video:
31k questions
32.8k answers
501 comments
693 users