Space face
Space face

Reputation: 19

How do I fix my Python program

import datetime

import time
import locale

now = datetime.datetime.now()

locale.setlocale(locale.LC_ALL, 'nl_NL')

geboortejaar = input("Wanneer ben je geboren? (jaar)")

leeftijd = 2017 - int(geboortejaar)

maand = int(input("En in welke maand? (getal)"))

dag = int(input("En op welke dag? (getal)"))

Weekdag = time.strftime("%d").upper()

Maand = time.strftime("%m").upper()

if maand >= Maand and dag >= Weekdag:
    print("Je bent dan " + str(leeftijd - 1) + " jaar oud en leeft al ongeveer " + str((leeftijd - 1) * 365) + " dagen!" )
else:
    print("Je bent dan " + str(leeftijd) + " jaar oud en leeft al ongeveer " + str(leeftijd * 365) + " dagen!")

I live in the Netherlands and I wanted to make a Program that tells you how old you are without having to change some things everyday but by taking calendar info. Can someone help me fix this?

Upvotes: 1

Views: 64

Answers (1)

Carlos Chicata Farfan
Carlos Chicata Farfan

Reputation: 51

this is a code in python:

from datetime import date

anio, month , day = map( int , raw_input().split())
birthday = date( anio, month, day)
now = date.today()
thetime = now - birthday
print("how old are you? the time is: ")
print("you have %s years" % (thetime.days/365))
print("you have %s days" % (thetime.days ) )

you can improve that by using dictionary to map string( representing a month ) to int( number of month ) to create a birthday variable more readible.

Upvotes: 1

Related Questions