skirt
unknown
plain_text
3 years ago
1.2 kB
3
Indexable
from datetime import datetime def current_date(): yyyy = int(datetime.today().strftime('%Y')) mm = int(datetime.today().strftime('%m')) dd = int(datetime.today().strftime('%d')) return yyyy,mm,dd def findAge(bYear, bMonth, bDay): # Find current date (yyyy, mm, dd) = current_date() # age = current year -birthday year age = yyyy - bYear # The details about months and days if ((mm < bMonth) or (mm == bMonth and dd < bDay)): age = age - 1 return age def printAgeDiff(persons): diff = persons[0] n = len(persons) for i in range(1, n): current = persons[i] dAge = findAge(diff[2], diff[3], diff[4]) cAge = findAge(current[2], current[3], current[4]) if dAge == cAge: print(diff[0], diff[1], "is at the same age as", current[0], current[1]) elif dAge > cAge: print(diff[0], diff[1], "is older than", current[0], current[1]) else: print(diff[0], diff[1], "is younger than", current[0], current[1]) diff = persons[i] printAgeDiff([['Justin','Bieber',1994,3,1], ['Donald','Duck',1934,8,1], ['George','Clooney',1961,5,6], ['Eddie','Murphy',1961,4,3]])
Editor is loading...