Created
October 22, 2017 03:28
-
-
Save tamago324/5a2d23f8a643928e56ac766769ae128f to your computer and use it in GitHub Desktop.
04. 元素記号
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
s = 'Hi He Lied Because Boron Could Not Oxidize Fluorine. New Nations Might Also Sign Peace Security Clause. Arthur King Can.' | |
result = {} | |
# enumerate()でループの回数を取得する | |
for i, elem in enumerate(s.split(), start=1): | |
# 指定番号かどうか | |
if {i} & {1, 5, 6, 7, 8, 9, 15, 16, 19}: | |
result[elem[0]] = i | |
else: | |
result[elem[0:2]] = i | |
# 結果出力 | |
for items in result.items(): | |
print(items) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment