error while passing the value in python

后端 未结 2 1225
死守一世寂寞
死守一世寂寞 2021-01-29 14:04
 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         


        
相关标签:
2条回答
  • 2021-01-29 14:32

    Your code has two nested definitions of user_input, so when you call it you get out the function definition instead of what it is supposed to return. Delete one of the def user_input(y): lines and fix your indentation and I bet it works.

    0 讨论(0)
  • 2021-01-29 14:44

    You may want something like this:

    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')
    

    Edit

    If you get something like <function user_input at 0x0000000002CB1128>, its because you are printing the function. (And it's not an error)

    print user_input # This is not wath you want
    

    This instead is what you want:

    print user_input(...) # Where ... is the parameter you are giving to your function
    
    0 讨论(0)
提交回复
热议问题