Untitled

Anonymous
plain_text
02/28/2024 7:42 AM
368 B
29
Indexable
def calculate_length(string):
    length = 0
    for _ in string:
        length += 1
    return length

def print_aligned_length(string):
    length = calculate_length(string)
    print(f"{length:>{length}} {string}")

# Example usage:
print_aligned_length("Hello, world!")
Editor is loading...
Leave a Comment