2 回答

TA貢獻1818條經驗 獲得超11個贊
這應該可以解決它
Senerio = 0
while Senerio not in (1, 2, 3, 4):
Senerio = int(input("choose a commission/Aggregation senerio number \n"
"1. put in car \n"
"2. put in plane \n"
"3. put on boat \n"
"4. put on fire "))
if Senerio == 1:
car = 1
plane = 0
boat = 0
fire = 0
def incar():
print('Im putting this in a car')
if car == 1:
incar()

TA貢獻1886條經驗 獲得超2個贊
我發(fā)現將我的if語句包裹在定義周圍給了我想要的東西,就像這樣:
if car == 1:
def incar():
print('Im putting this in a car')
incar()
incar
添加回答
舉報