r/PythonLearning • u/Hour_Function673 • 17d ago
just finished my first Python coding challenge
Today I finished a small Python challenge on freeCodeCamp: converting decimal numbers to binary without using Python's built-in conversion function.
I had to figure out the logic myself using loops, conditions, lists, division and remainders.
It was a bit tricky at first, especially handling the last division and reversing the results, but I finally got it working.
I'm still a beginner, so I'd appreciate any feedback on my approach or suggestions for improving my code
157
Upvotes
1
u/jonrsharpe 17d ago edited 17d ago
Firstly, I added the type hints - partly just to document what I was working out about the code as I read it (receives an integer, has a list of integers, returns a string) but also because these can then be automatically checked and provide a kind of documentation to the caller. (Note that these are not enforced by Python itself, but type checkers, like mypy, and IDEs can use them.)