what is Pythons best practice for multiple elifs? I would like to write the following function in a more beautiful or structured way. Is there anything like switch case built in? How would a pro structure this? I am still beginner :-) Thanks in advance!
def getThreshold(i=0.00):
if i <= 500:
return i * 1.1
elif i <= 1000:
return i * 1.4
elif i <= 2000:
return i * 1.1
elif i <= 3000:
return i
elif i <= 5000:
return i * 0.85
elif i <= 10000:
return i * 0.7
elif i <= 20000:
return i * 0.7
elif i <= 100000:
return i * 0.75
else:
return i * 0.8
Aucun commentaire:
Enregistrer un commentaire