LoginSignup
0
0

More than 3 years have passed since last update.

Python勉強の記録_190819

Posted at

やったこと

  • 競技プログラミング続き
  • やさしく始めるラズベリー・パイを読み始めた

学び

  • Global
#local
a = "before"
def sample():
    a = "after"
print(a) #before
sample()
print(a) #before

#global
a = "before"
def sample():
    global a
    a = "after"
print(a) #before
sample()
print(a) #after
  • リストのcountとindex
lst = [1,1,4,6,7]
print(lst.count(1))
#2
print(lst.index(6))
#3
print(lst.index(1))
#0(最初にある要素のインデックスを表示)
print(lst.index(0))
#エラー
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