1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Python勉強の記録_190812

Posted at

#やったこと

#学び

  • リストの昇順・降順並び替え(昇順にしてからじゃないと降順にできないのでしょうか)
lst = [1, 7, 5]
lst.sort()
print(lst)
#[1, 5, 7] <--昇順
lst.reverse()
print(lst)
#[7, 5, 1] <--降順
  • set型(集合。重複しないリスト)の扱い方
#set型オブジェクト作成
set1 = set([1, 1, 2, 3])
print(set1)
#{1, 3, 2}

#要素の追加
set1.add(5)
print(set1)
#{1, 2, 3, 5}
  • プログラムを終了
    import sysしないでも通った)
exit()
  • 文字列の置換
l = "letter"
l2 = l.replace('t', 'T')
print(l2)
#"leTTer"
1
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
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?