Find The Longest And Shortest Strings And Lengths In A Python List
You can the shortest and longest items in a Python list of strings by using [TODO: Code shorthand span ] with the built - in [TODO: Code shorthand span ] and [TODO: Code shorthand span ] functions.
For example :
python
=
=
=
Outputs :
Iowa
Pennsylvania
A useful addition is to call [TODO: Code shorthand span ] on the results to find the lengths.
For example :
python
=
=
=
Outputs :
4
12
Short and sweet.
Happy coding.