Python Forum
How to append to a set in Python
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to append to a set in Python
#7
(Oct-01-2020, 03:25 PM)Marbelous Wrote: The dict on line 12 is essentially random.
That is not dict, but set. Otherwise you are right - it's unordered collection
Just to clear something about dicts - as of 3.7 dicts preserve insertion order. This was also true in 3.6 but as implementation detail.

Also let say that you can do
lst = [3, 3, 22, 22, 1, 4, 5, 6, 10, 20, 40, 40, 40, 50]
dup_free_set = set(lst)
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply


Messages In This Thread
How to append to a set in Python - by dgrunwal - Oct-01-2020, 02:18 PM
RE: How to append to a set in Python - by ndc85430 - Oct-01-2020, 02:23 PM
RE: How to append to a set in Python - by dgrunwal - Oct-01-2020, 03:16 PM
RE: How to append to a set in Python - by Marbelous - Oct-01-2020, 03:25 PM
RE: How to append to a set in Python - by bowlofred - Oct-01-2020, 03:29 PM
RE: How to append to a set in Python - by buran - Oct-01-2020, 03:32 PM
RE: How to append to a set in Python - by ndc85430 - Oct-01-2020, 04:27 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Building a DoublyLinkedList in Python - - append method Drone4four 2 375 Jan-08-2024, 01:27 PM
Last Post: Drone4four
  How to modify python script to append data on file using sql server 2019? ahmedbarbary 1 1,177 Aug-03-2022, 06:03 AM
Last Post: Pedroski55
  Including modules in Python using sys.path.append JoeDainton123 1 2,851 Aug-24-2020, 04:51 AM
Last Post: millpond
  How to append a tuple full of records to a dbf file in Python? DarkCoder2020 4 3,648 May-29-2020, 02:40 PM
Last Post: DarkCoder2020
  Cant Append a word in a line to a list err "str obj has no attribute append Sutsro 2 2,525 Apr-22-2020, 01:01 PM
Last Post: deanhystad

Forum Jump:

User Panel Messages

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