Hello tutors, I need to find the shortest / longest word(s) in a sequence of words. I've done this and it works, but I'm wondering whether this is a good way: >>> words = "man woman children he".split() >>> words ['man', 'woman', 'children', 'he'] >>> lens = [len(word) for word in words] >>> lens [3, 5, 8, 2] >>> for word in words: ... if len(word) == min(lens): print word ... he >>>
-- لا أعرف مظلوما تواطأ الناس علي هضمه ولا زهدوا في إنصافه كالحقيقة.....محمد الغزالي "No victim has ever been more repressed and alienated than the truth" Emad Soliman Nawfal Indiana University, Bloomington --------------------------------------------------------
_______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor