String Zfill in Python
Level 230 keystrokes
This pads a string with zeros on the left. The zfill() method fills until the specified width is reached.
Python code
# Create a 2-character string (a number stored as text)1num = "42"# zfill(5) adds zeros on the left until the string is 5 characters long# Three zeros are added, so it prints 000422print(num.zfill(5))Output
00042
Practice typing this code. Results are not recorded in the rankings.
Symbols in this code
The symbols you type in this Python code and how often they appear.
"× 2(× 2)× 2.× 1=× 1