定義功能print_popcorn_time()
與參數bag_ounces
。如果bag_ounces
小於3,則打印「太小」。如果大於10,則打印「太大」。否則,計算並打印6 * bag_ounces
,然後加上「秒」。以換行符結束。例如輸出bag_ounces = 7
:功能分支
42 seconds.
對於這個程序我得到吸吮的錯誤:
"File "main.py", line 6 elif bag_ounces = bag_ounces * 6" ^
def print_popcorn_time(bag_ounces):
if bag_ounces < 3:
print("Too small")
elif bag_ounces > 10:
print("Tool large")
elif bag_ounces = bag_ounces * 6
else:
print(bag_ounces)
print_popcorn_time(7)
'='用於分配。你想'=='比較。 – Carcigenicate
雖然我不認爲他想比較。 – Kevin
什麼是錯誤? –