我想要一個轉數計數器,只計算探索和狩獵選項1轉。並將其添加到當前時代。我怎樣才能做到這一點?我使用python 2.7。下面的代碼的重要部分:如何計算蟒蛇中的轉數2.7
from main import name
import os
import random
kenyan_sand_boa = {
"snek": "kenyan sand boa",
"prey": "mice, " "birds, " "lizards",
"biome": "desert",
"predators": "desert monitor lizard",
"adult age": 156,
"baby size": 10,
"adult size": 20,
"current size": 10,
"current age": "0",
"name": name,
}
os.system('cls')
def menu():
os.system('cls')
print '''Now that you have chosen what snek to be, you have a couple
options
1. Read info about kenyan sand boas.
2. Explore.
3. Hunt.
4. View inventory.
5. Save.
6. Exit.
'''
loop = 1
choice = 0
while loop == 1:
menu()
choice = int(raw_input())
if choice == 1:
#information about kenyan sand boas
if choice == 2:
#exploring
if choice == 3:
#huntinng
if choice == 4:
#view inventory
else:
menu()
trun = 0; ..... if .... turn + = 1? –
謝謝。這是完美的。 –
在頂部有'INFO = 1','EXPLORING = 2','HUNTING = 3'和'INVENTORY = 4'可能很有用。這將允許你做'如果選擇== INFO:'等等。另外,你可以把所有的'if'在第一個之後改爲'elif's。 – user2471379