Python Forum
Zip on single element in nested sequence.
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Zip on single element in nested sequence.
#1
How do I create the list c=[2,3,4] from the list a=[[1,2,3],[2,3,4],[3,4,5]]? In other words, how do I create a list from element [1] of a list containing nested sequences?

I know b,c,d=zip(*a) produces b=[1,2,3], c=[2,3,4], and d=[3,4,5].  That works well, but I don't need b and d.  It seems I should be able to use zip(*a[1]) or something of the sort but I have no success.

This is a minor problem but I must be missing something obvious.

my code here
Reply


Messages In This Thread
Zip on single element in nested sequence. - by rhubarbpieguy - Jun-28-2017, 12:23 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  ValueError: dictionary update sequence element #0 has length 1; 2 Jmekubo 4 35,990 Apr-28-2019, 07:25 PM
Last Post: Jmekubo
  Unable to locate element no such element gahhon 6 4,648 Feb-18-2019, 02:09 PM
Last Post: gahhon
  Using xpath to get value of a nested element name using tag named xq1xq1xq1 3 9,689 Jan-18-2019, 07:13 PM
Last Post: Larz60+
  Replace element in a nested list nagymusic 4 18,049 Nov-19-2018, 08:03 PM
Last Post: nilamo
  Change single element in 2D list changes every 1D element AceScottie 9 12,260 Nov-13-2017, 07:05 PM
Last Post: Larz60+
  Using nested for loop with a single list mikeavison 3 3,385 Aug-12-2017, 08:13 PM
Last Post: ichabod801
  Executing single unittest over a sequence volcano63 1 3,900 May-11-2017, 11:11 AM
Last Post: volcano63

Forum Jump:

User Panel Messages

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