0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

1.インデントの後に「...」をつける

hoge = True
if hoge:
else:

if文の内容を書く途中、中が空だとエラーになります。
そんな時は'...'と書きましょう!

hoge = True
if hoge:
    ...
else:
    ...

2.関数に説明を書く

関数の最初に「""" """」を書くと関数の説明ができます!

def hoge() -> None:
    """
    This is sample define for qiita
    """
    print("huga")
    return None

3.for文省略

fruits = ["apple","banana","orange"]
fruits_2 = []
fruits_3 = []

for i in fruits:
   fruits_2.append(i.replace("a",""))

fruits_3 = [i.replace("a","") for i in fruits]

fruits_2fruits_3は同じです!省略できると便利ですよ!

注意

使いすぎると、コードが読みづらくなります。
そのときは普通にfor文を書きましょう!

読んでくれてありがとうございます

コメント、いいねもよろしくお願いします:cheese::cake:

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?