-3
 def row_minimum(x,L):
  L=L
  if x=='1':
    row_minimum1=min(L[0],L[1],L[2],L[3],L[4])
    return row_minimum1
  elif x=='2':
    row_minimum2=min(L[5],L[6],L[7],L[8],L[9])
    return row_minimum2
  elif x=='3':
    row_minimum3=min(L[10],L[11],L[12],L[13],L[14])
    return row_minimum3
  table(L)


 def user_input(y):
    def user_input(y):
        if y in ['1','2','3','A','B','C','D','E']:
            condition = False
        elif y !=['1','2','3','A','B','C','D','E']:
            condition = True
            while condition == True:
                z=input("Enter a row (as a number) or a column (as and uppercase letter):")
                if z in ['1','2','3','A','B','C','D','E']:
                    condition = False
            return z

def  menu(a,L):
  if a==1:
    display_table(L)
  elif a==2:
    x=input("Enter a row (as a number) or a column (as and uppercase letter):")
    user_input(x)
    print (user_input)
    if user_input(x) in ['1','2','3']:
        mini = row_minimum(x,l)
        print ("2")
        print("Minimum is:",row_minimum(x,L))

这是检查用户输入的程序,但每当我传递输入时,它都会通过函数,但它在 0x021DCB28> 处为 user_input(y) 提供了一个内置函数函数 user_input

4

2 回答 2

0

您的代码有两个嵌套定义user_input,因此当您调用它时,您会得到函数定义而不是它应该返回的内容。删除其中def user_input(y):一行并修复您的缩进,我敢打赌它可以工作。

于 2013-10-31T04:52:39.497 回答
0

你可能想要这样的东西:

def user_input(y):
    if y in ['1','2','3','A','B','C','D','E']:
        condition = False
    else:
        condition = True
        while condition == True:
            z=input("Enter a row (as a number) or a column (as and uppercase letter):")
            if z in ['1','2','3','A','B','C','D','E']:
                condition = False
        return z


print user_input('1')
print user_input('4')

编辑

如果你得到类似的东西<function user_input at 0x0000000002CB1128>,那是因为你正在打印这个函数。(这不是错误)

print user_input # This is not wath you want

这反而是你想要的:

print user_input(...) # Where ... is the parameter you are giving to your function
于 2013-10-31T04:06:26.940 回答