def convert_time_to_minutes(time_str):
        hours, minutes = time_str.split('h')
        hours = int(hours.strip())

        if minutes.strip('m '):
            minutes = int(minutes.strip('m '))
            minutes = 0  # Set minutes to 0 if it's an empty string

        total_minutes = hours * 60 + minutes
        return total_minutes
    except ValueError:
        print(f"Invalid time format: {time_str}")
        return None

# Example usage
time_str = "2h 40m"
converted_minutes = convert_time_to_minutes(time_str)

output : 160


Login here

Forgot your password?



I am an enthusiastic advocate for the transformative power of data in the fashion realm. Armed with a strong background in data science, I am committed to revolutionizing the industry by unlocking valuable insights, optimizing processes, and fostering a data-centric culture that propels fashion businesses into a successful and forward-thinking future. - Masud Rana, Certified Data Scientist, IABAC

© Data4Fashion 2023-2024

Developed by:

Please accept cookies
Accept All Cookies