History Separation
Write a program that receives a historical in yyyy/mm/dd format and prints year, month and day
Write a program that receives a historical in yyyy/mm/dd format and prints year, month and day
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) |
def date(**a): | |
for i in a: | |
print(i,a[i]) | |
date(year='2024',month='11',day='22') |
date_in = input ("Enter yyy/mm/dd : ") | |
year,mounth, day = date_in.split("/") | |
print (f"Year:{year} , mounth:{mounth} , Day{day}") |
#get input | |
tarikh = input("Enter the date like yyyy/mm/dd : ") | |
#split | |
joda = tarikh.split("/") | |
print("th year is : "+joda[0]) | |
print("th month is : "+joda[1]) | |
print("th day is : "+joda[2]) |
Submitting answers is currently unavailable.
برای استفاده از این بخش باید وارد حساب کاربریت بشی
ورود/ثبت نام If you don’t understand the exercise or can’t solve it for any reason, that’s completely
normal—don’t worry 😊
Try checking out easier exercises and reviewing different answers
submitted by others. Gradually, you can move on to more challenging exercises. Also, your answer
might be correct even if it’s different from others.