Nov-15-2019, 05:09 AM
(This post was last modified: Nov-15-2019, 05:09 AM by northduckota.)
Hello, I'd like to make my code output
Here is my code
10 10 0000000abc abc0000000What I'm I doing wrong with my code right now. All suggestions would be very much appreciated!
Here is my code
def pad_string(data, size, padding_character=' ', direction='left'): """This new function will determine if it will pad to the left or the right by using an if statement.""" if direction == 'left': data = data.rjust(size, padding_character) elif data == 'right': data = data.ljust(size, padding_character) return data def pad_left(data, size, padding_character=' '): """This new function will call pad_string and use it to pad to the left""" result_left = pad_string(data, size, padding_character, 'left') return result_left def pad_right(data, size, padding_character=' '): """This new function will call pad_string and use it to pad to the left""" result_right = pad_string(data, size, padding_character, 'right') return result_right # Output Test Code print(len(pad_left('abc', 10))) print(len(pad_right('abc', 10))) print(pad_left('abc', 10, '0')) print(pad_right('abc', 10, '0'))