【发布时间】:2018-05-05 12:09:32
【问题描述】:
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
在 if 块中 isascend 和 isdescend 没有定义显示“未解析的引用”,但为什么? 为什么不能调用函数?在python中定义函数是否遵循某种顺序。 我该如何解决这个问题?我是编程和符号表概念的新手。
【问题讨论】:
-
你在哪里定义了
isascend?
标签: python python-3.x symbol-table