8000 Solution for task: Converting 12-hour time to 24-hour time. · ZaytsevNS/python_codewars@d1e0da9 · GitHub
[go: up one dir, main page]

Skip to content

Commit d1e0da9

Browse files
committed
Solution for task: Converting 12-hour time to 24-hour time.
1 parent 2f6198e commit d1e0da9

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

7KYU/to24hourtime.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Solution for task: https://www.codewars.com/kata/59b0a6da44a4b7080300008a/
2+
3+
from datetime import datetime
4+
5+
6+
def to24hourtime(hour: int, minute: int, period: str) -> str:
7+
time = datetime.strptime(f"{hour}:{minute} {period}", "%I:%M %p")
8+
return time.strftime("%H%M")

0 commit comments

Comments
 (0)
0