lundi 21 décembre 2015

How do I get the if statement to display the zeros ONLY the year(s) outputted an integer?(preferably positive)

How to display how many years months weeks and days someone has until inputted date

currentDate = datetime.date.today()
deadline = input('Enter the deadline of your project (mm/dd/yyyy): ')
deadline = datetime.datetime.strptime(deadline,'%m/%d/%Y').date()
deadline = deadline - currentDate
deadline = deadline.days

deadlineYears = (deadline)//(365)
deadlineMonths = (deadline)//(30.4167)
deadlineWeeks = (deadline)//(7)
deadlineDays = (deadline)

deadlineYears = math.floor(deadlineYears)
deadlineMonths = math.floor(deadlineMonths)
deadlineWeeks = math.floor(deadlineWeeks)

if (deadlineDays not in {1-364}):#<-PROBLEM
deadlineMonths = 0
deadlineWeeks = 0
deadlineDays = 0

deadlineYears = str(deadlineYears)
deadlineMonths = str(deadlineMonths)
deadlineWeeks = str(deadlineWeeks)
deadlineDays = str(deadlineDays)
print ('You have ' + deadlineYears + ' year(s), ' + deadlineMonths + ' month(s), ' + deadlineWeeks + ' week(s), and ' + deadlineDays + ' day(s).')

I can't get it to display the zeros only when the year outputted is whole

Aucun commentaire:

Enregistrer un commentaire