Project すぅぃった Python version. NO.02b

import os
# os.system('cls')のため
import sys
# sys.exit()のため
import msvcrt
# msvcrt.getch()のため

#	以下はサンプルプログラム
#	SCENARIO_TEST_02.py

#	選択のID
sel_btnext_pre  = "a"
sel_btnext_post = "a"
#   入力文字列
input_str = ""
while 1:
    if sel_btnext_pre  == "a":
        if sel_btnext_post == "a":
            os.system('cls')
            while 1:
                print("aかsかdか、")
                print("fかgかhを入力してください")
                print("終了:q")
                input_str = msvcrt.getch()
                input_str = str(input_str)
                if input_str == "b'q'":
                    sel_btnext_pre  = "a"
                    sel_btnext_post = "quit"
                    break
                if input_str == "b'a'":
                    sel_btnext_pre  = "b"
                    sel_btnext_post = "ba"
                    break
                if input_str == "b's'":
                    sel_btnext_pre  = "b"
                    sel_btnext_post = "bs"
                    break
                if input_str == "b'd'":
                    sel_btnext_pre  = "b"
                    sel_btnext_post = "bd"
                    break
                if input_str == "b'f'":
                    sel_btnext_pre  = "c"
                    sel_btnext_post = "cf"
                    break
                if  input_str == "b'g'":
                    sel_btnext_pre  = "c"
                    sel_btnext_post = "cg"
                    break
                if  input_str == "b'h'":
                    sel_btnext_pre  = "c"
                    sel_btnext_post = "ch"
                    break
                # end of while
            # end of if
        if sel_btnext_post == "quit":
            print("bye")
            sys.exit()
            # end of if
            
    if sel_btnext_pre  == "b":
        if sel_btnext_post == "ba":
            print("あなたはaを押しましたね")
            input_str = msvcrt.getche()
            sel_btnext_pre  = "a"
            sel_btnext_post = "a"
            print("")
            # end of if

        if sel_btnext_post == "bs":
            print("あなたはsを押しましたね")
            input_str = msvcrt.getche()
            sel_btnext_pre  = "a"
            sel_btnext_post = "a"
            print("")
            # end of if

        if sel_btnext_post == "bd":
            print("あなたはdを押しましたね")
            input_str = msvcrt.getche()
            sel_btnext_pre  = "a"
            sel_btnext_post = "a"
            print("")
            # end of if

    if sel_btnext_pre  == "c":
        if sel_btnext_post == "cf":
            print("あなたはfを押しましたね")
            input_str = msvcrt.getche()
            sel_btnext_pre  = "a"
            sel_btnext_post = "a"
            print("")
            # end of if

        if sel_btnext_post == "cg":
            print("あなたはgを押しましたね")
            input_str = msvcrt.getche()
            sel_btnext_pre  = "a"
            sel_btnext_post = "a"
            print("")
            # end of if

        if sel_btnext_post == "ch":
            print("あなたはhを押しましたね")
            input_str = msvcrt.getche()
            sel_btnext_pre  = "a"
            sel_btnext_post = "a"
            print("")
            # end of if
    # end of while