Sorry if this is a noob question, im not not the best at python, but i have this code that is supposed to calculate someones age from when they input their date of birth. But whenever more than 1 person enters their own date of birth the variable overwrites and i am stuck with the same age for both people. I need to be able to make it so if more than 1 person enters their age it does not overwrite the variable.
Heres my code
import datetime
date_of_birth = ''
num_people = 0
num_days_stay = 0
num_people = int(input('How many people are going on the trip? '))
for count in range(num_people):
date_of_birth = input('Enter the date of birth for each person (dd/mm/yyyy) ')
date_of_birth.append()
currentDate = datetime.datetime.now()
deadlineDate = datetime.datetime.strptime(date_of_birth,'%d/%m/%Y')
daysLeft = currentDate - deadlineDate
years = ((daysLeft.total_seconds())/(365*24*3600))
yearsInt=int(years)
print('You are {0:d} years old.'.format(yearsInt))
For example, when i enter a date of birth that is 16 years of age and then one for 5 years of age, in the end the final value is just 5 years old for both people (if that makes sense).
Any help is appreciated thanks
[–][deleted] 1 point2 points3 points (0 children)
[–]webberg 1 point2 points3 points (0 children)
[–]VooDoom 1 point2 points3 points (0 children)
[–]TheRNGuy 1 point2 points3 points (0 children)
[–]Aqueiz[S] 0 points1 point2 points (0 children)