I need a self contained function that does / returns the formatted string, rather than formatting the string after it is returned.
None of the other questions, here and here, were asking what I wanted for the keywords I was using.
Asked
Active
Viewed 43 times
1 Answers
0
Answering my own question
def right_just_string(string):
# return a string that is padded by say 10 chars
return str(f'{string:>10}')
thing = 'cat'
print(thing)
print(right_just_string(thing))
returns
cat
cat
Yes it's simple but I was asking the question when my string and formatting was complex - I didn't even know it was possible

DaftVader
- 105
- 1
- 11