Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
hmm, it looks like you’re new to coding in general. ex1 and ex2 look fine.
Instead of using format, use f strings: https://realpython.com/python-f-str...
Work on more substantial problem. Whenever I learn a new language, I like to overengineer a simple problem with more advanced features (regex, lambdas, function pointers, etc). -
rotho98186y@toriyaki thank you, I will have a look at f strings. I can see how they can make cleaner looking code
-
mpie2346yFirst example has a typo: your should be you and the function is wrong...
If I am 8 and I turn 9 tomorrow. It would say the year where I turn 101 instead of 100 😉 -
rotho98186y@mpie thanks for pointing the typo. To stop the date confused I ask the user what age they turn this year. Obviously I could implement something that looks of the date and month have already past. If it hasn't add 1 to the year count
-
mpie2346yAlso make your code readable.
Instead of:
if num % 2 == 0 and num % 4 == 0:
Do:
if (num % 2) == 0 and (num % 4) == 0:
I know it’s not necessary in Python, but there are more languages out there. Might help you in the future.
Related Rants
So I'm relatively new to Python. I've started doing the practicepython.org challenges. What do you guys think to my code layout, is there any way I can improve.
https://github.com/Rotho98/...
question
newbie
feedback
python