0
0

More than 1 year has passed since last update.

paizaラーニング「重複の削除 Python3編」

Posted at

私の解答

li = [1, 3, 5, 1, 2, 3, 6, 6, 5, 1, 4]

new_li = []
 
for ele in li:
    if ele not in new_li:
        new_li.append(ele)

sorted_new_li = sorted(new_li)
for ele in sorted_new_li:
    print(ele)

解答例

li = [1, 3, 5, 1, 2, 3, 6, 6, 5, 1, 4]

li_set = set(li)
sorted_li_set = sorted(li_set)

for ele in sorted_li_set:
    print(ele)

set(li)で重複の削除を行うことを覚えました。

0
0
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
0