Skip to content

Instantly share code, notes, and snippets.

@Chizuchizu Chizuchizu/main.py
Created Dec 18, 2018

Embed
What would you like to do?
百人一首の練習
import random
import pandas as pd
def load():
return pd.read_csv("百人一首.csv")
def loop(simo, kami):
while True:
n = random.randint(0, 99) # 詠む番号を決める
i = 0
while True:
j = 1
simo_n = simo[n]
kami_n = kami[n]
print("", j, "問目】下の句は", simo_n, "\n")
s = input()
if s == "end": # endは終了
break
if kami_n == s: # 正解ならもう次のループ
print("正解です!\n")
break
else:
print("不正解です…")
while i < 3:
print("後2回チャンスを与えます")
if len(kami_n) != 1:
print("上の句の一文字目は", kami_n[0])
s = input()
if s == "end":
break
if kami_n == s:
print("正解です")
break
else:
print("不正解です")
if i == 2:
print("正解は", kami_n)
i += 1
break
j += 1
if s == "end":
break
def main():
df = load() # データの読み込み
kami = df[""]
simo = df[""]
# ルール説明
print("【チズチズの決まり字特訓】\n")
print("【ルール】")
print("下の句(決まり字)を詠むので、上の句の決まり字を答えて下さい。")
print("辞めたかったら「end」って言ってね!\n")
loop(simo, kami)
if __name__ == "__main__":
main() # 実行
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.