python - How to check change between two values (in percent)? -
i have 2 values (previous , current) , want check change between them (in percent):
(current/previous)*100   but if previous value 0 division zero, , if value not change 100%.
def get_change(current, previous)     if current == previous:         return 100.0     try:        return (abs(current - previous))/previous)*100.0     except zerodivisionerror:         return 0      
Comments
Post a Comment