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
let msg = 'error' alert(msg)This answer is only visible to premium members
This answer is only visible to premium members
let msg = 'error' alert(msg)This answer is only visible to premium members
This answer is only visible to premium members
let msg = 'error' alert(msg)This answer is only visible to premium members
This answer is only visible to premium members
while True : day = input("Enter day(1-31) : ") month = input("Enter month(1-12) : ") year = input("Enter year(yyyy) : ") if len(day) > 2 or not 1 <= int(day) <= 31 : print("Please enter a valid(1-31) : ") continue if len(month) > 2 or not 1 <= int(month) <= 12 : print("Please enter a valid(1-12) : ") continue if len(year) != 4 or not year.isdigit() : print("Please enter a valid(yyyy) : ") continue break print(f"{year}/{month.zfill(2)}/{day.zfill(2)}")
i=input('tarikh ra vared konid mesal(1373/01/15):') y,m,d=i.split('/') print(y,'year') print(m,'month') print(d,'day')
# this is python code to split date: date=input("enter the date in this format: yyyy/mm/dd") y=[] m=[] d=[] for i in range(10): if i<=3: y.append(date[i]) elif i>4 and i<7: m.append(date[i]) elif i>=8 : d.append(date[i]) print( "your date is: year: ",''.join(y),"mount is :",''.join(m), "and day is:", ''.join(d) )
dateInput = input("Enter date with this format(yyyy/mm/dd):") print(f"day = {dateInput[-2:]}") print(f"month = {dateInput[5:7]}") print(f"year = {dateInput[0:4]}")
tarikh = int (input("what yor tarikh : ") sal=trikh[0:4] mah= tarikh[4:6] roz=tarikh[6:] mah1={"01" : "farvardin " , "02" : "ordibehesht", "03" : "khordad" ,"04" : "tir" , "05" :"mordad" , "06": "sharivar" ,"07" : "mehr" , "08" : "aban" , "09" :"azar" , "10" : "day" , "11" : "bahman" , "12" : "esfand"} print (f"sal \n, mah={mah1} \n, roz \n")
date = input("Enter a date in yyyy/mm/dd format: ") year, month, day = date.split('/') print(f"Year: {year}") print(f"Month: {month}") print(f"Day: {day}")
No need to create additional variables and occupy memory that has been modified above
x = input('please enter date like 2024/11/28 ...') x = x.split('/') print(f'Year is {x[0]}') print(f'Month is {x[1]}') print(f'Day is {x[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.