Input time value | SoloLearn: Learn to code for FREE!

+47

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

Aad Hoogenboom

14 Answers

New Answer

+6

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.

+34

Military Time

+2

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

+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

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

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

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

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

-1

-1

import datetime time=int(datetime.datetime.now().hour) if time ==12 : Print("Noon") else : print("Not noon")

-1

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