Tuesday, 10 September 2013

returning values greater than the target value

returning values greater than the target value

I'm trying to figure out how to change this code. Instead of counting the
number of times that the target value appears, I want to be able to return
the number of values in the list that are greater than the target value.
def countTarget2(myList, target):
counter = 0
for element in myList:
if element == target:
counter = counter + 1
return counter
Do I change the 5 line too?
counter > counter + 1

No comments:

Post a Comment