Bottom Page

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 get the one element from 1-list or 1-set
i have a list or tuple or set or frozenset with exactly one element within. i'd like to code a simple way to get that one element that can be used with any of those container types. i can't use x[0] since that does not work with set or frozenset .
What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
next(iter(x)) perhaps?
Skaperen likes this post

Top Page

Possibly Related Threads...
Thread Author Replies Views Last Post
  Why does pop() removes an element from more than one list? albufork 5 126 Nov-17-2019, 08:01 AM
Last Post: buran
  can't remove element from a list yokaso 6 159 Nov-06-2019, 03:11 PM
Last Post: yokaso
  Select a part of an element of a list with Index BollerwagenIng 0 297 Aug-09-2019, 09:27 AM
Last Post: BollerwagenIng
  Replace a list or string element with a random one.. pianistseb 3 338 May-09-2019, 08:24 AM
Last Post: buran
  Extract a List element NewBeie 4 456 May-03-2019, 09:49 AM
Last Post: NewBeie
  How to list number of times element is in defaultdict and delete it mrapple2020 3 346 Apr-15-2019, 07:34 AM
Last Post: perfringo
  Unable to locate element no such element gahhon 6 611 Feb-18-2019, 02:09 PM
Last Post: gahhon
  Converting List of 3 Element Tuple to Dictionary fooikonomou 11 1,106 Jan-14-2019, 09:51 AM
Last Post: perfringo
  Replace element in a nested list nagymusic 4 2,778 Nov-19-2018, 08:03 PM
Last Post: nilamo
  Accessing first list element when at end of loop! JY450 1 445 Aug-14-2018, 12:50 PM
Last Post: perfringo

Forum Jump:

Users browsing this thread: 1 Guest(s)