Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

convert 1 digit to 2 digit python

number = 10
print(number) #Output: 10
zero_filled_number = str(number).zfill(3)
print(zero_filled_number) #Output: "010"
Comment

how to format integer to two digit in python

You can achieve this using formatted string
num = 1
number = f"{num:02}"
--------------
output:
"01"
Comment

PREVIOUS NEXT
Code Example
Python :: python get int from string 
Python :: drop columns pandas 
Python :: triangle pygame 
Python :: Write a Python program to append text to a file and display the text. 
Python :: pytho list items to int 
Python :: install postgres for python mac 
Python :: generate matrix python 
Python :: install gtts 
Python :: how to blit text in pygame 
Python :: format date field in pandas 
Python :: python get minute from datetime 
Python :: how to get a list of all values in a column df 
Python :: python check if list contains elements of another list 
Python :: pyspark session 
Python :: pandas dataframe histogram 
Python :: python print version python 
Python :: built in functions python 
Python :: calculate mape python 
Python :: python string list to float 
Python :: flask how to run app 
Python :: how to split channels wav python 
Python :: selenium keep window open python 
Python :: how to make jupyterlab see other directory 
Python :: django and react url conflict 
Python :: install tkinter python 3 mac 
Python :: pyspark import stringtype 
Python :: open a filename starting with in python 
Python :: python read excel set index 
Python :: how to get pygame window height size 
Python :: taking string input from user in python 
ADD CONTENT
Topic
Content
Source link
Name
3+6 =