LoginSignup
0
1

More than 3 years have passed since last update.

集合のメソッド add remove clear

Last updated at Posted at 2020-01-15
1
s = {1, 2, 3, 4, 5}
s.add(6)
print(s)
1の実行結果
{1, 2, 3, 4, 5, 6}
2
s = {1, 2, 3, 4, 5}
s.remove(5)
print(s)
2の実行結果
{1, 2, 3, 4}
3
s = {1, 2, 3, 4, 5}
s.clear()
print(s)
3の実行結果
set()

空の辞書{}と区別する為に、
空集合はset()と表す。

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1