Untitled
unknown
plain_text
2 years ago
275 B
8
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