私は Mac で python 2.5.4 を使用している初心者の python ユーザーです。ここ数日間、Python でゲームの株式ティッカー (テキストのみ) を作成しようとしており、ほとんど完成していますが、while ループで「構文エラー: 無効な構文」が発生しています。これは、5 行目でエラーが発生し、while の e を指している ^ を取得するという問題を引き起こしているコードの一部です。(私は全部を投稿しますが、300行以上あります)
while (keep_going ==0):
sell_var = int(raw_input('Please choose what you would like to sell, for grain enter 1, for technology enter 2, for ore enter 3, for construction enter 4, for bonds enter 5, and for trade enter 6, to skip enter any other key'))
if sell_var == 1:
temp_sell = int(raw_input('How many grain stock would you like to sell?')
while (temp_sell > playgrain[x]):
temp_sell = int(raw_input('Please choose a different amount to sell, you do not have that many stock')
playgrain[x] = playgrain[x]-temp_sell
playmoney[x] = playmoney[x] + stock[1] * temp_sell
if sell_var == 1:
temp_sell = int(raw_input('How many technology stock would you like to sell?')
while (temp_sell > playertech[x]):
temp_sell = int(raw_input('Please choose a different amount to sell, you do not have that many stock')
playtech[x] = playtech[x]-temp_sell
playmoney[x] = playmoney[x] + stock[2] * temp_sell
if sell_var == 1:
temp_sell = int(raw_input('How many ore stock would you like to sell?)
while (temp_sell > playore[x]):
temp_sell = int(raw_input('Please choose a different amount to sell, you do not have that many stock')
playore[x] = playore[x]-temp_sell
playmoney[x] = playmoney[x] + stock[3] * temp_sell
if sell_var == 1:
temp_sell = int(raw_input('How many construction would you like to sell?)
while (temp_sell > playconst[x]):
temp_sell = int(raw_input('Please choose a different amount to sell, you do not have that many stock')
playconst[x] = playconst[x]-temp_sell
playmoney[x] = playmoney[x] + stock[4] * temp_sell
if sell_var == 1:
temp_sell = int(raw_input('How many bonds stocks would you like to sell?)
while (temp_sell > playbonds[x]):
temp_sell = int(raw_input('Please choose a different amount to sell, you do not have that many stock')
playbonds[x] = playbonds[x]-temp_sell
playmoney[x] = playmoney[x] + stock[5] * temp_sell
if sell_var == 1:
temp_sell = int(raw_input('How many trade stock would you like to sell?)
while (temp_sell > playtrade[x]):
temp_sell = int(raw_input('Please choose a different amount to sell, you do not have that many stock')
playtrade[x] = playtrade[x]-temp_sell
playmoney[x] = playmoney[x] + stock[6] * temp_sell