Menu
Newbedev LogoNEWBEDEV Python Javascript Linux Cheat sheet
Newbedev LogoNEWBEDEV
  • Python 1
  • Javascript
  • Linux
  • Cheat sheet
  • Contact

The leading zeroes challenge

Pyth, 12 bytes

%"%0*d",+E>0

Try it here!


Python 2, 29 bytes

lambda x,y:x.zfill(y+(x<'.'))

Try it online!

Just str.zfill comes so close.


Python, 29 bytes

Take input as f(x,y). Using Python's % operator.

lambda x,y:'%0*d'%(y+(x<0),x)

Try it online!

Tags:

String

Code Golf

Related

Coffee Machine Machine Golf an Advent Calendar Circular Keyboard Spiral Parse my Esperanto! What do I need to destroy the world? Minimal sparse rulers Build an Electrical Grid "Early bird" squares Find the password Is it a whole number? Scoop me an icecream please Is it bipartite?

Recent Posts

Pandas how to find column contains a certain value Recommended way to install multiple Python versions on Ubuntu 20.04 Build super fast web scraper with Python x100 than BeautifulSoup How to convert a SQL query result to a Pandas DataFrame in Python How to write a Pandas DataFrame to a .csv file in Python
© 2021 newbedevPrivacy Policy