Python學習三級菜單

import sys
def _exit():
sys.exit('退出程序')
for d in data:
print(d)
while True:
choice=input('輸入你要查詢的內容:')
if choice in data:
while True:
for d1 in data[choice]:
print(d1)
choice1 = input('輸入你要查詢的漫畫:')
if choice1 in data[choice]:
while True:
for d2 in data[choice][choice1]:
print(d2)
choice2 = input('輸入你要查看的人物:')
if choice2 in data[choice][choice1]:
while True:
for d3 in data[choice][choice1][choice2]:
print(d3)
choice3 = input('輸入你想看的選項:')
if choice3 in data[choice][choice1][choice2]:
for d4 in data[choice][choice1][choice2][choice3]:
print(d4)
print('是否繼續查詢: q退出')
user_gone = input('請輸入您的選擇:')
if user_gone != 'q':
pass
else:
pass
elif choice3 == '':
print('輸入不能爲空')
elif choice3 == 'q':
_exit()
elif choice3 == 'b':
break
else:
print('該選項不存在')

                elif choice2 == '':
                    print('輸入不能爲空')
                elif choice2 == 'q':
                    _exit()
                elif choice2 == 'b':
                    break
                else:
                    print('查詢內桶不存在')

        elif choice1 =='':
            print("輸入不能爲空")
        elif choice1 =='q':
            _exit()
        elif choice1 == 'b':
            break
        else:
            print('查找內容不存在')

elif choice == '':
    print('查詢內容不能爲空')
elif choice =='q':
    _exit()
elif choice == 'b':
    break
else:
    print('查詢內容不存在')
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章