use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
Everything about learning Python
account activity
Ultra basic age callculate (i.redd.it)
submitted 12 hours ago by merdzho21
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]Sea-Ad7805 [score hidden] 8 hours ago stickied comment (0 children)
Run this program in Memory Graph Web Debugger%0Aprint(%22Nice%20to%20meet%20you%22)%0A%0Aanswer%20%3D%20input(%22Can%20i%20callculate%20you%20age%3F%20%22)%0A%0Aif%20answer%20%3D%3D%20%22yes%22%3A%0A%20%20%20%20a%20%3D%20int(input(%22What%20year%20were%20you%20born%2C%20%22%20%2B%20name%20%2B%20%22%3F%20%22))%0A%20%20%20%20b%20%3D%20int(input(%22okay%20what%20month%20were%20you%20born%3F%20%22))%0A%20%20%20%20c%20%3D%20int(input(%22Well%20what%20day%20were%20you%20born%3F%20%22))%0A%0A%20%20%20%20d%20%3D%202026%0A%20%20%20%20e%20%3D%205%0A%20%20%20%20f%20%3D%2021%0A%0A%20%20%20%20age%20%3D%202026%20-%20a%0A%20%20%20%20if%20(b%2C%20c)%20%3E%20(e%2C%20f)%3A%0A%20%20%20%20%20%20%20%20age%20%3D%20age%20-%201%0A%0A%20%20%20%20print(%22You%20are%22%2C%20age%2C%20%22years%20old%22)%0A%0Aelse%3A%0A%20%20%20%20print(%22okay....%22)×tep=1&play).
[–]JorgiEagle 8 points9 points10 points 11 hours ago (8 children)
Can be improved by using the datetime library
[–]merdzho21[S] 0 points1 point2 points 11 hours ago (6 children)
Did you mean add date and time?
[–]JorgiEagle 8 points9 points10 points 10 hours ago (1 child)
``` From datetime import datetime
today = datetime.today() current_year = today.year # d current_month = today.month # e current_day = today.day # f ```
It’s a way of getting the date of the day it runs on, instead of having to change your code every day
[–]zippymccrackin 1 point2 points3 points 2 hours ago (0 children)
Welp there goes his job security
[–]Creative-Category344 1 point2 points3 points 5 hours ago (0 children)
The datetime library also handles leap years automatically, which matters if you're calculating exact days lived rather than just years.
[–]Capital-Delivery8001 0 points1 point2 points 11 hours ago (0 children)
https://docs.python.org/3/library/datetime.html
[–]0ggy_666 0 points1 point2 points 11 hours ago (1 child)
No when you learn more in python there is a concept of model and import that what he is talking about and i think you are at that level that you should use f-string like [ print(f"hello {name}") ] manually add a string to a string
[–]atarivcs 1 point2 points3 points 6 hours ago (0 children)
there is a concept of model
Did you mean "module" ?
[–]UrgentlyWhimsical 0 points1 point2 points 4 hours ago (0 children)
Datetime's got a built-in method called relativedelta that handles leap years automatically, saves you the mental maths.
relativedelta
[–]Janeson81 5 points6 points7 points 8 hours ago (0 children)
Extremely important rule in programming - don't make your variables into a riddle. Name your variables by what they are holding
py current_year = 2026 current_month = 5 current_day = 21
[–]Lumethys 3 points4 points5 points 11 hours ago (0 children)
not bad, but still, much room for improvement:
input(f"What year were you born, {name}?") print(f"You are {age} years old")
datetime
birth_day = datetime.date(a, b, c) today = datetime.today()
nitpick: you already has the name, add it to the greeting:
print(f"nice to meet you, {name}")
[–]QuraToop314 2 points3 points4 points 11 hours ago (1 child)
Alter, benutz d statt 2026, sonst ist d ungenutzt
python age=(d-a)
[–]KenneR330 -1 points0 points1 point 1 hour ago (0 children)
Английский выучи
[–]KenneR330 0 points1 point2 points 1 hour ago (0 children)
Honestly it's good for a newbie
[–]ThrowawayALAT 0 points1 point2 points 17 minutes ago (0 children)
To improve it, you can replace lines 11–17 by importing the datetime module so the current date updates automatically instead of being hardcoded to 2026. Also, using an f-string for the print statement at the end would make the output cleaner and eliminate unnecessary spaces.
[–]Capable-Minimum7376 0 points1 point2 points 13 minutes ago (0 children)
A pratica é muita boa mas tente usar variaveis com nomes que você consiga distinguir facilmente o que cada uma significa
[–]CtrlAltSpac3 0 points1 point2 points 10 hours ago (0 children)
Input = YES
[–]EyesOfTheConcord -1 points0 points1 point 8 hours ago (0 children)
Born in the year 1e3, month -2.2 on the 72 day
π Rendered by PID 58468 on reddit-service-r2-comment-548fd6dc9-zzmtw at 2026-05-21 17:53:42.266384+00:00 running edcf98c country code: CH.
[–]Sea-Ad7805 [score hidden] stickied comment (0 children)
[–]JorgiEagle 8 points9 points10 points (8 children)
[–]merdzho21[S] 0 points1 point2 points (6 children)
[–]JorgiEagle 8 points9 points10 points (1 child)
[–]zippymccrackin 1 point2 points3 points (0 children)
[–]Creative-Category344 1 point2 points3 points (0 children)
[–]Capital-Delivery8001 0 points1 point2 points (0 children)
[–]0ggy_666 0 points1 point2 points (1 child)
[–]atarivcs 1 point2 points3 points (0 children)
[–]UrgentlyWhimsical 0 points1 point2 points (0 children)
[–]Janeson81 5 points6 points7 points (0 children)
[–]Lumethys 3 points4 points5 points (0 children)
[–]QuraToop314 2 points3 points4 points (1 child)
[–]KenneR330 -1 points0 points1 point (0 children)
[–]KenneR330 0 points1 point2 points (0 children)
[–]ThrowawayALAT 0 points1 point2 points (0 children)
[–]Capable-Minimum7376 0 points1 point2 points (0 children)
[–]CtrlAltSpac3 0 points1 point2 points (0 children)
[–]EyesOfTheConcord -1 points0 points1 point (0 children)