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?

More than 5 years have passed since last update.

今週のPython学習内容

0
Posted at

これは、今週個人的に学習した内容をアウトプットした記事です

print()関数で複数の文字列を改行なしで出力する方法

print()関数のオプション引数 end=”” を渡す.""の中に半角スペースを入れることで、半角空けながら改行なしで出力する。

 例;
 for n in range(2):
    print (n,end=" ")

結果;
0 1

対象の文字列が、ある文字列のリストに現れる回数を数える方法

回数を数えるmatchingStringsメソッド(stringsはある文字列のリスト、queriesは対象文字列のリスト);
for querie in queries:
    x.append(strings.count(querie))

mapの使い方

map()は、リストの要素に演算を適用してくれる関数です。

例;
>>> def square(x):
...     return x * x
...
>>> list(map(square, range(1, 6)))
[1, 4, 9, 16, 25]
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?