Python: Union of Two or More Sets

Post Reply
User avatar
Jason
Site Admin
Posts: 853
Joined: Tue Jul 01, 2025 10:13 am

Code: Select all

first_set_of_Southwest_Virginia_counties = set((Washington, Smyth, Russell, Scott))

second_set_of_Southwest_Virginia_counties = set((Lee, Wise))

print(f "The first set of Southwest Virginia counties is {first_set_of_Southwest_Virginia_counties}. and the second set is {second_set_of_Southwest_Virginia_counties}.")

bigger_set_of_Southwest_Virginia_counties= first_set_of_Southwest_Virginia_counties.union(second_set_of_Southwest_Virginia_counties)

print(f "The first set of counties joined to the second produce {bigger_set_of_Southwest_Virginia_counties}.")

 

POSTREACT(ions) SUMMARY

Post Reply