Calculating Year, Month and Day of Life

hokiegal99 hokiegal99 at hotmail.com
Sat Jul 5 19:48:31 CEST 2003


Hello,

I am a funeral director trying to write a small program that calculates 
the number of years, months and days a person has lived by entering the 
year, month and day of their birth. This is what I have so far:

#---------------------
from time import *
local = localtime()

print "Enter the year of birth:"; y = input()
print "Enter the month of birth:"; m = input()
print "Enter the day of birth:"; d = input()

age = y,m,d
print age
print local
#----------------------

The output looks similiar to this:
(1934, 2, 7)
(2003, 7, 5, 13, 20, 0, 5, 186, 1)

My problem is that localtime is a list of 9 integers while age is a list 
of 3 integers. Is it possible to make localtime() only return the first 
3 integers? If so, how would I then do calculations on the two lists' 
individual parts? For example, how would I instruct localtime() to 
subtract the first integer from age's list from the first intger in its 
own list (2003 - 1934)?

Also, I am new to python, but I like it a lot and have picked it up 
quickly. If my approach to this solving this problem is completely 
wrong, please point me in the right direction.

Thanks in advance!!!





More information about the Python-list mailing list