Back

Explore Courses Blog Tutorials Interview Questions
0 votes
1 view
in Python by (19.9k points)

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 true

a = [6, 5, 4, 3, 2]

print(monotonic(a))

And I get the following error:

NameError: global name 'true' is not defined

1 Answer

0 votes
by (25.1k points)

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: 

Related questions

0 votes
1 answer
asked Nov 28, 2020 in Python by ashely (50.2k points)
0 votes
1 answer
0 votes
1 answer

Browse Categories

...