私はこの小さなゲームを作ろうとしています。何らかの理由で、「Y」と入力すると「あなたはリンゴを選んでみませんか?私は何をしようと、ITは1にとどまります。ここに私のコードはあります:なぜリンゴは増えていないのですか?
import time
global choice
global gold
global apples
apples = 0
gold = 0
def begin():
apples = 0
gold = 0
print ("Let's go!")
if gold > 99:
print ("You've won the game!")
play = input ("Do you want to play again? Please answer Y/N.")
if play == "Y":
begin()
if play == "N":
print ("Okay, bye then.")
pick = input ("Do you want to pick an apple Y/N?")
if pick == "Y":
print ("You pick an apple")
apples=apples+1
apples = 1
print ("You currently have,",apples," apples")
begin()
if pick == "N":
sell = input("Do you want to sell your apples Y/N?")
if sell == "Y":
gold
apples
print ("You currently have,",apples,"apples")
print("You have sold your apples")
gold=apples*10
print ("Your gold is now:",gold)
begin()
start()
print ("Hello and welcome!")
name = input("What's your name?")
print ("Welcome, "+name+"!")
print ("The goal of this game is to collect apples")
print ("After you have collected these applaes, you sell them.")
choice = input("Do you want to play? Type Y/N.")
if choice == "Y":
begin()
if choice == "N":
print ("Okay, bye then.")
誰でもこの問題を手伝うことができたら非常に感謝します。私はちょうど初心者なので、あまりにも厳しくはありません。この問題が明らかな場合は申し訳ありませんが、私はちょうど始めたばかりです。