0

私はコンピューター サイエンス専攻の 1 年生で、自分が何をしているのかについてほとんど手がかりがなく、本当に助けが必要です。ユーザーが 3 つの株式から 1 つを選択するシミュレーションを実行する割り当て用のプログラムを作成しており、プログラムは 10 年間の利益/損失を計算します。

現在、利益と損失のランダム セクションを実装しようとしていますが、エラーの解析中に予期しない eof が発生し続けています。

コードの最後の 2 行を削除すると、エラーは消えます。

私はウェブサイトでこれに対する以前の解決策を検索しましたが、私が言ったように、私はプログラミングに非常に慣れておらず、これらの質問に投稿された解決策を理解するのに十分なPythonに堪能ではありません.

import random


def main():
    starting_menu()
    choice_loop()

#Displays the starting menu 
def starting_menu():
    spendingCash=float(100.00)
    print("Current funds:", format(spendingCash, "0.2f"))
    print("Available investments")
    print("(1)Fly-By-Night investments (SCAMU): high risk, high potential returns")
    print("(2)Blue Chips INC (BCI): moderate risk, good yearly returns")
    print("(3)Slow and Steady Corp (BORE): mature industry, no risk but low returns")
    print("\nPlease enter a value from 1-3 only")
    print()

#Loop for if user selects a stock numbered other than 1-3
def choice_loop():
    chosen_stock=int(input("Stock Selection: "))

    while chosen_stock>3 or chosen_stock<1:
        print("Invalid choice, please enter number from 1-3 only")
        chosen_stock=int(input("Stock Selection: "))

    invest_chance=random.randrange(1,101)
    if chosen_stock==1:
        if invest_chance>=1 and invest_chance<=45:

助けてくれてありがとう。

4

1 に答える 1