在python中传递值时出错

时间:2013-10-31 04:01:53

标签: python

 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。 for user_input(y)

1 个答案:

答案 0 :(得分: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