-1
t=int(input("enter no of test cases"))
global mylist1,mylist2

for a in range(t):
    n = int(input("number of cubes"))
    while True:
        list_inp = input("enter list").split()
        if len(list_inp)== n:
            break
        print("no of list items is not equal to specified length.")
    mylist=[int(x) for x in list_inp]                            

    x = min(mylist)             
    y = mylist.index(x)                                     
    mylist1 = mylist[0:x]                                   
    mylist2 = mylist[x:]

    if isascend(mylist2) and isdescend(mylist1):    
        print('yes')                                

    else:
        print('no')





def isdescend(mylist1):                     
    previous = mylist1[0]
    for number in mylist1:
        if number > previous:
            return False
        previous = number
    return True




def isascend(mylist2):      
    previous = mylist2[0]
    for number in mylist2:
        if number < previous:
            return False
        previous = number
    return True

In the if block isascend and is descend are not defined showing "unresolved reference" but why?? Why the function cannot be called?Is there some kind of order followed for defining a function in python. how can i resolve this?? I'm new to programming &symbol table concept.

Aran-Fey
  • 39,665
  • 11
  • 104
  • 149
Enji
  • 83
  • 1
  • 10

1 Answers1

0

You need to define the functions before the code that uses them.

Zarkonnen
  • 22,200
  • 14
  • 65
  • 81
  • yes, i tried that also but its still showing same error. it's only working when i m defining function in the for loop. I think a function should be called from anywhere....i'm missing the underlying concepts .. – Enji May 06 '18 at 04:36