Python Set Explained: Why set([1,2,3]) Works but set(1,2,3) Fails? | Logic behind sets
In this video, you’ll understand the real reason Python uses square brackets inside set(), and why the parentheses are not “creating a set” at all. We break down the set constructor in Python: set() is a function, and the () simply call it. The input must be a single iterable (like a list, tuple, string, or range), so set([1, 2, 3]) works because [1, 2, 3] is a list (an iterable). But set(1, 2, 3) fails because you are passing multiple arguments instead of one iterable. You’ll also see correct alternatives like set((1,2,3)) and set("abc"). If you’re confused about Python set syntax, set() vs {}, or how to remove duplicates using Python Set, this will make it clear with simple examples. _____________________________________________________________________ YouTube https://www.youtube.com/c/LearningVibes Facebook page Learning vibes https://www.facebook.com/learningvibesbymruduraj Learning vibes electrical engineering https://www.facebook.com/learningvieselectricalengineering Facebook group Learning Vibes https://www.facebook.com/groups/817014689212925 https://www.facebook.com/groups/learningvibes Telegram Group https://t.me/learningvibesgroup Channel https://t.me/mjlearningvibes Instagram account https://www.instagram.com/learning_vibes/ ___________________________________________________________________________
Download
0 formatsNo download links available.