Python Error saying "NameError: global name 'true' is not defined"

0 votes

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
Jun 17 in Python by Trisha
36 views

1 answer to this question.

0 votes
It's a very small mistake. Change true to True. It should work. Python is case-sensitive.
answered Jun 17 by Vinayak

Related Questions In Python

0 votes
1 answer

Python error "Python NameError: global name 'Thread' is not defined"

There is a built-in function with the ...READ MORE

answered May 31 in Python by Riya
55 views
0 votes
0 answers

Python error saying "NameError: name 'email' is not defined"

I get the following error while executing ...READ MORE

Jun 13 in Python by Kamal

edited Jun 13 36 views
0 votes
1 answer

Python argparse error "NameError: name 'file' is not defined"

The right datatype for destination in argpasrse module ...READ MORE

answered Nov 28, 2018 in Python by Omkar
• 67,120 points
972 views
0 votes
2 answers
+1 vote
2 answers

how can i count the items in a list?

Syntax :            list. count(value) Code: colors = ['red', 'green', ...READ MORE

answered Jul 6 in Python by Neha
• 330 points

edited Jul 8 by Kalgi 133 views
+4 votes
6 answers
0 votes
1 answer
0 votes
1 answer

Check a number is Prime or not in Python

There is an efficient way to write ...READ MORE

answered Oct 26, 2018 in Python by Priyaj
• 56,160 points
122 views