Compare length of two strings: Difference between revisions

m
Line 1,041:
===Advanced solution===
{{works with | Python | 3.8}}
 
The solution below has some imperfection. When the longest strings of characters are of equal length, instead of describing them as "''one of the longest''" they are described as "''the longest''". This works similarly for the shortest strings. Also, if all strings (in this case where there is only one) have the same length it is not printed that they are the shortest strings. Of course, this could be improved.
 
<lang Python>"""
An example code for the task "Compare length of two strings" (Rosseta Code).
Line 1,084 ⟶ 1,087:
lengths_and_objects = zip(lengths, objects)
 
# Longer phrases make translationtranslations into other natural languages easier.
#
has_length = _('has length')