What is the method to add elements to a Python set?

There are two ways to add elements to a Python set.

  1. include()
  2. insert()
集合.add(元素)

For example,

s = {1, 2, 3}
s.add(4)
print(s)  # 输出:{1, 2, 3, 4}
  1. refresh()
  2. – refresh()
集合.update(可迭代对象)

Can you give me a hand with this project?

Can you help me with this project?

s = {1, 2, 3}
s.update([4, 5, 6])
print(s)  # 输出:{1, 2, 3, 4, 5, 6}
bannerAds