We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
- Time Conversion
- Discussions
Time Conversion
Time Conversion
Sort by
recency
|
342 Discussions
|
Please Login in order to post a comment
Kotlin Solution
!/bin/python3
import math import os import random import re import sys
#
Complete the 'timeConversion' function below.
#
The function is expected to return a STRING.
The function accepts STRING s as parameter.
#
def timeConversion(s): # Write your code here period=s[-2:] hours,minutes,seconds=map(int,s[:-2].split(':')) if period=='AM' and hours==12: hours=0 elif period=='PM' and hours !=12: hours+=12 return f"{hours:02}:{minutes:02}:{seconds:02}"
if name == 'main': fptr = open(os.environ['OUTPUT_PATH'], 'w')
c++20 (chose readability over latency)
def timeConversion(s): period = s[-2:] #last two digits = pm/am time = s[:-2] #without last two digits = time hms = list(map(int, time.split(':'))) #splits the list and converts str into int in one line