Jan-02-2022, 03:27 PM
(This post was last modified: Jan-02-2022, 04:27 PM by BashBedlam.)
Does anyone know of a simpler way to display information with a dot leader?
def add_dot_leader (text) :
new_text = ''
for index in range (1, len (text), 2) :
thing_one = text [index - 1]
thing_two = text [index]
if thing_one == ' ' and thing_two == ' ' :
new_text += ' .'
else :
new_text += thing_one + thing_two
if len (new_text) < len (text) :
new_text += text [-1]
return new_text
record = {'Name': 'Roy Rodgers',
'Age': 'unknown',
'Occupation': 'Retired'}
print ()
for label, information in record.items () :
print (add_dot_leader (f'\t{label:16}{information}'))Like this :Output: Name . . . . . Roy Rodgers
Age . . . . . . unknown
Occupation . . Retired
