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
  Finding an element in a 1d list in a 2d array lionrocker221 0 193 Jun-27-2020, 04:50 PM
Last Post: lionrocker221
  removing dictionary element in list using (key, value) MelonMusk 3 165 Jun-13-2020, 02:37 PM
Last Post: buran
  using element on a list as condition statement glennford49 11 462 May-21-2020, 12:53 PM
Last Post: hussainmujtaba
  count each element in a list glennford49 9 419 May-01-2020, 11:20 AM
Last Post: glennford49
  Alpha numeric element list search rhubarbpieguy 1 185 Apr-01-2020, 12:41 PM
Last Post: pyzyx3qwerty
  Why does pop() removes an element from more than one list? albufork 5 315 Nov-17-2019, 08:01 AM
Last Post: buran
  can't remove element from a list yokaso 6 395 Nov-06-2019, 03:11 PM
Last Post: yokaso
  Select a part of an element of a list with Index BollerwagenIng 0 501 Aug-09-2019, 09:27 AM
Last Post: BollerwagenIng
  Replace a list or string element with a random one.. pianistseb 3 541 May-09-2019, 08:24 AM
Last Post: buran
  Extract a List element NewBeie 4 672 May-03-2019, 09:49 AM
Last Post: NewBeie

Forum Jump:

Users browsing this thread: 1 Guest(s)