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

        if minutes.strip('m '):
            minutes = int(minutes.strip('m '))
        else:
            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)
print(converted_minutes)




output : 160

Register

Login here

Forgot your password?

ads

ads

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: Behostweb.com

Please accept cookies
Accept All Cookies