Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Minimum size
#6
You are on right track (lines # 6 and 7) but slight adjustments needed.

You need:

- find minimum length from list elements
- find elements which length is equal to minimum length

>>> lst = [['1', '6', '66', '9', '33'], 
...        ['1', '6', '9', '33'], 
...        ['1', '66', '6', '9', '33'], 
...        ['1', '66', '9', '33'], 
...        ['1', '4', '9', '33']] 
>>> shortest = min(len(row) for row in lst) 
>>> shortest
4
>>> [row for row in lst if len(row) == shortest] 
[['1', '6', '9', '33'], ['1', '66', '9', '33'], ['1', '4', '9', '33']]
I'm not 'in'-sane. Indeed, I am so far 'out' of sane that you appear a tiny blip on the distant coast of sanity. Bucky Katt, Get Fuzzy

Da Bishop: There's a dead bishop on the landing. I don't know who keeps bringing them in here. ....but society is to blame.
Reply


Messages In This Thread
Minimum size - by Amniote - Jul-08-2019, 09:14 PM
RE: Minimum size - by nilamo - Jul-08-2019, 09:18 PM
RE: Minimum size - by Amniote - Jul-08-2019, 10:19 PM
RE: Minimum size - by Gribouillis - Jul-08-2019, 09:32 PM
RE: Minimum size - by Gribouillis - Jul-09-2019, 06:37 AM
RE: Minimum size - by perfringo - Jul-09-2019, 06:58 AM
RE: Minimum size - by Amniote - Jul-09-2019, 07:49 AM
RE: Minimum size - by perfringo - Jul-09-2019, 09:00 AM
RE: Minimum size - by nilamo - Jul-10-2019, 02:58 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  How to get indices of minimum time difference Mekala 1 2,256 Nov-10-2020, 11:09 PM
Last Post: deanhystad
  How to get index of minimum element between 3 & 8 in list Mekala 2 2,653 Nov-10-2020, 12:56 PM
Last Post: DeaD_EyE
  Finding MINIMUM number in a random list is not working Mona 5 3,223 Nov-18-2019, 07:27 PM
Last Post: ThomasL
  Delete minimum occurence in a string RavCOder 10 4,214 Nov-12-2019, 01:08 PM
Last Post: RavCOder
  size of set vs size of dict zweb 0 2,223 Oct-11-2019, 01:32 AM
Last Post: zweb
  Armstrong in minimum lines Gaurav 1 2,080 Sep-03-2018, 03:46 PM
Last Post: j.crater
  Watson Personality Insight: minimum number of words kiton 0 2,844 Apr-28-2018, 03:28 PM
Last Post: kiton
  CSV file created is huge in size. How to reduce the size? pramoddsrb 0 10,617 Apr-26-2018, 12:38 AM
Last Post: pramoddsrb
  Python find the minimum length of string to differentiate dictionary items zydjohn 3 3,798 Mar-03-2018, 05:23 PM
Last Post: Gribouillis
  Product of maximum in first array and minimum in second Thethispointer 9 5,585 Jan-19-2018, 07:38 PM
Last Post: Thethispointer

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020