Python Forum
Questions about elements in dict
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Questions about elements in dict
#3
(Feb-08-2020, 03:07 AM)stullis Wrote: The key here is mutability. Tuples are immutable - they cannot be changed. As such, they are hashable and can be used as elements of a set. Conversely, lists are mutable and cannot be used as set elements.

my_set[2] raises an error because the set has only one element. That element, the tuple, has four elements of its own.

Thanks. In this case, how do I access individual element(s) in the tuple which is the only element in the dict? As far as I know, there is no ordering among the elements in a set.
Reply


Messages In This Thread
Questions about elements in dict - by new_to_python - Feb-08-2020, 01:44 AM
RE: Questions about elements in dict - by stullis - Feb-08-2020, 03:07 AM
RE: Questions about elements in dict - by new_to_python - Feb-08-2020, 04:25 AM
RE: Questions about elements in dict - by ndc85430 - Feb-08-2020, 05:25 AM
RE: Questions about elements in dict - by perfringo - Feb-08-2020, 07:05 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  questions about dict.get akbarza 2 260 Apr-19-2024, 01:53 PM
Last Post: deanhystad
  ValueError: Length mismatch: Expected axis has 8 elements, new values have 1 elements ilknurg 1 5,197 May-17-2022, 11:38 AM
Last Post: Larz60+
  Sorting Elements via parameters pointing to those elements. rpalmer 3 2,634 Feb-10-2021, 04:53 PM
Last Post: rpalmer
  Sort a dict in dict cherry_cherry 4 77,894 Apr-08-2020, 12:25 PM
Last Post: perfringo
  dict elements are sometimes treated as List and sometimes as String phython_mdr 4 2,737 Apr-01-2020, 12:47 PM
Last Post: phython_mdr
  Discord bot that asks questions and based on response answers or asks more questions absinthium 1 41,856 Nov-25-2017, 06:21 AM
Last Post: heiner55

Forum Jump:

User Panel Messages

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