+61

# Input time value

How can I compare the time in Python3 with an input of 00:00. For example, input 12:00 print it is noon.

5/2/2020 4:08:35 PM

A H

+8

If you're assuming 24h format input time, you can use hours, minutes = list(map(int, input_time.split(":"))) Now that you have the hours and minutes to work with, everything follows.

+41

Military Time

+3

Cyber Death heyyy m not Kimbo Ghayal It's Kiibo Ghayal

+3

def convert24(str1): # Checking if last two elements of time # is AM and first two elements are 12 if str1[-2:] == "AM" and str1[:2] == "12": return "00" + str1[2:-2] # remove the AM elif str1[-2:] == "AM": return str1[:-2] # Checking if last two elements of time # is PM and first two elements are 12 elif str1[-2:] == "PM" and str1[:2] == "12": return str1[:-2] else: # add 12 to hours and remove PM return str(int(str1[:2]) + 12) + str1[2:8] # Driver Code print(convert24("08:05:45 PM"))

+1

You may find answer in https://www.hackerearth.com/practice/python/getting-started/input-and-output/tutorial/

+1

Vishnu your code is full of mistakes , plz correct it

+1

import java.util.Scanner; public class Program { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int days = scanner.nextInt(); //your code goes here } }

0

Aad Hoogenboom is it an ordinal time or military Time?

0

create three lists: list1 would have numbers that you would consider "morning" list2 would have numbers the you would consider "afternoon" list3 would have numbers the you would consider "evening" myinput = int(input().split(':')[0]) if you need "Noon" and "midnight" specifically....you would need to test for 12 and 00 and amend the lists accordingly. Use if ... in .....: blah blah blah.

0

It works in my mac , maybe you dont have datetime installed

0

Please stop disliking every little thing I type , instead of commenting on other's fault, atleast i am attempting to solve it . This code works , even on the Sololearn coding for python

0

Vishnu I'm not interested to know which device you are using But For your kind information, I want to add your mistakes 1. Import willl be started with small i 2.You have not taken input from user 3.at last you have not mentioned that, input is in military Time Hope it helped

0

The capital thing happened by mistake , On my phone it automatically capitalized it

-1

Fuck