I have a function with two inputs the numeric and the threshold. I want to compute the boolean statement true if the numeric is greater than the threshold. Upon computing my code I get the following error message:
'<' not supported between instances of 'int' and 'list'
See code:
num_list =([10, 1, 3, 7])
result =[]
def hits(num_list,threshold=5):
for x in num_list:
if threshold<num_list:
return true
CodePudding user response:
You are iterating through the for loop with x
, but don't actually call x
in the loop. Replace the conditional line with if threshold<x
to access the variable x
(int) instead of num_list (list). That's why you're getting the error about trying to compare an int and a list.