my_set={'a','b','c','d','e'}
my_set2=my_set.copy()
print(my_set2)
Output is here
{'d', 'a', 'b', 'c', 'e'}
Modifying a Copy:original_set = {1, 2, 3}
copied_set = original_set.copy()
copied_set.add(4)
print(copied_set) # Output: {1, 2, 3, 4}
print(original_set) # Output: {1, 2, 3}
Using Copy for Set Operations:set1 = {'apple', 'banana'}
set2 = set1.copy()
set2.remove('banana')
print(set2) # Output: {'apple'}
All set methods Questions with solutions on set discard()
Author
🎥 Join me live on YouTubePassionate about coding and teaching, I publish practical tutorials on PHP, Python, JavaScript, SQL, and web development. My goal is to make learning simple, engaging, and project‑oriented with real examples and source code.