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 1 year has passed since last update.

アルファベットの辞書を3行で作成する方法

Posted at

を解いててアルファベットの辞書列を作成するのを自動化したかった。備忘録的に保存

参照:https://teratail.com/questions/71512

コード

python3
alpha_dict = {}
for i,c in enumerate(range(ord('A'),ord('Z')+1)):
    alpha_dict[chr(c)] = i + 1

出力

{'A':1, 'B':2, 'C':3, ... 'Z':26}

・enumerate:for文内で値のみならずインデックスも取得できる
・ord(str):Unicordを取得できる。例) ord("A") = 65, ord("Z") = 90

という感じ

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?