I am trying to check if a number is in range of integers and returns a number based on which range it lies. I was wondering if is there a better and more efficient way of doing this:
def checkRange(number):
if number in range(0,5499):
return 5000
elif number in range( 5500, 9499 ):
return 10000
elif number in range( 9500 , 14499 ):
return 15000
elif number in range( 14500 , 19499 ):
return 20000
elif number in range( 19500,24499 ):
return 25000
elif number in range( 24500,29499 ):
return 30000
elif number in range( 29500,34499 ):
return 35000
elif number in range( 34500-39499 ):
return 40000
elif number in range( 39500,44499 ):
return 45000
This felt like a waste of resources and would greatly appreciate if there is a better way to do this.
Aucun commentaire:
Enregistrer un commentaire