On 18/02/12 18:35, Deborah Knoll wrote:
make sure the numbers entered are greater than 0 and less than 1001
(can't get this) - is there a way to write a "between" statment or an "or"??
Several replies have shown how to do "between".
To use or you would do:
if n < 0 or n > 1001:
# handle error
else:
store value
##def aboveAverage():
## total = 0.0
##
## for value in amount:
## total +=amount[index]
## average = total/len(amount)
An alternative solution here uses a list comprehension
def aboveAverage(amounts, ave):
return len( [item for item in amounts if item > ave] )
HTH,
--
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
_______________________________________________
Tutor maillist - [email protected]
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor