Method # 1: Using
This task can be accomplished with a simple built-in string function ljust, em> where we just need to pass no. the element to the right pad is also required of zeros, in this case zero.
The original string: GFG T he string after adding trailing zeros: GFG0000
Method # 2: Using
Formatting Strings using the formatting function can be easily used for this task, we just mention the total number of elements, the number of elements needed to fill, and the direction of the filling, in this case it is correct.
The original string: GFG The string after adding trailing zeros: GFG0000