Untitled

mail@pastecode.io avatar
unknown
plain_text
8 months ago
275 B
2
Indexable
Never
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!")
Leave a Comment