私はメニュー システムのテンプレートに取り組んでおり、初心者向けに非常によく整理されています。過去数日間、stackoverflow を通じていくつかの良い助けが得られたので、ここで何が問題なのかを尋ねてみようと思いました。
コードは次のとおりです。
# Multitasker
# Allows User to Pick an Item that is Defined.
# This is the initial screen.
print("""
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
X X
X DEMO MULTITASK DEMO X
X X
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
X X
X MULTITASKING X
X -------------------- X
X MAIN MENU SYSTEM X
X FOR GAME PLATFORMS X
X -------------------- X
X X
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
PRESS 'ENTER' TO CONTINUE""",end=" ")
# Input used to prevent the Multitask Selector Menu from Appearing at First!
input(" ")
# Defining Task 1
def task1():
print("""
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
X YOU HAVE CHOSEN TO DISPLAY TASK 1 X
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
""", end=" ")
# Defining Task 2
def task2():
print("""
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
X YOU HAVE CHOSEN TO DISPLAY TASK 2 X
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
""", end=" ")
# Defining Task 3
def task3():
print("""
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
X YOU HAVE CHOSEN TO DISPLAY TASK 3 X
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
""", end=" ")
# Defining Task 4
def task4():
print("""
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
X YOU HAVE CHOSEN TO DISPLAY TASK 4 X
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
""", end=" ")
# If the Player Selected an innappropriate task number greater than 4, this will display.
def notatask():
print("""
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
X THAT IS NOT A POSSIBLE CHOICE. X
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
""", end=" ")
# Starts choice off as having no selection.
choice = None
playername = " "
# While the variable 'choice' is not '0', it will continue to display the menu below
while choice != "0":
print(
"""
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
X X
X MULTITASK SELECTION X
X X
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
X X
X 0 - Quit X
X 1 - Task 1 X
X 2 - Task 2 X
X 3 - Task 3 X
X 4 - Task 4 X
X X
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
""", end=" ")
choice = int(input("\n\t\tPick a Task Between 0-4:\t#"))
print()
# Exit
if choice == int('0'):
print("""
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
X X
X DEMO MULTITASK DEMO X
X X
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
X X
X MULTITASKING X
X -------------------- X
X MAIN MENU SYSTEM X
X FOR GAME PLATFORMS X
X -------------------- X
X X
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
""", end="")
print("\t\t", playername, end="")
print("""
PRESS 'ENTER' TO CONTINUE""", end=" ")
input(" ")
# Task 1
elif choice == int('1'):
task1()
# Task 2
elif choice == int('2'):
task2()
# Task 3
elif choice == int('3'):
task3()
# Task 4
elif choice == int('4'):
task4()
# Not a Correct Selection
elif choice > int('4'):
notatask()
# Enter Key
elif choice == ('ENTER'):
notatask()
だから、私が理解していないのは、誰かが0、1、2、3、または4以外のキーを押したときに notatask() を呼び出すために何をする必要があるかということです.
誰かが私を正しい方向に導くことができますか?
前もって感謝します。
一番、
スティーブン