CodeSolved

A comprehensive source of programming questions and exercises

History Separation

Practice Easy 1383/ Download 665 Views

Write a program that receives a historical in yyyy/mm/dd format and prints year, month and day

14 Answers

from datetime import datetime
def print_date_parts(date_str):
date_obj = datetime.strptime(date_str, "%Y/%m/%d")
year = date_obj.year
month = date_obj.month
day = date_obj.day
print(f"Year: {year}")
print(f"Month: {month}")
print(f"Day: {day}")
date_input = "2024/11/22"
print_date_parts(date_input)
date_in = input ("Enter yyy/mm/dd : ")
year,mounth, day = date_in.split("/")
print (f"Year:{year} , mounth:{mounth} , Day{day}")
User 918 Download Python
#get input
tarikh = input("Enter the date like yyyy/mm/dd : ")
#split
joda = tarikh.split("/")
#print
print("th year is : "+joda[0])
print("th month is : "+joda[1])
print("th day is : "+joda[2])
Itsmrpm Download Python
<< Previous page 1 2 Next Page >>

Submit answer

Submitting answers is currently unavailable.

×
×