Pythonプログラムで少し問題があります。それは "統計"のようなコマンドを入力することができ、それは "天気:"、 "日:"、 "気温:"を返すか、または日を設定するために "日"を入力することができ、設定する "天気"天気ですので、あなたは "統計"で見ることができます。すべてのコマンドの最後に、「コマンド入力」が再び表示されます。最初のコマンドを入力すると、コマンドが正常に表示され、 "command input"が再び表示されます(別のコマンドを入力したとき)。別のコマンドを入力すると、入力したものが出力されます。Pythonプログラムでエラーが発生しました
temp = "";
wea = "";
day = "";
input1 = input("What do you want: ");
if input1 == "stats":
print ("Day: " + day)
print ("Temperature: " + temp);
print ("Weather: " + wea);
input1 = input("What do you want: ");
elif input1 == "day":
input2 = input("Set a day: ");
day=input2;
input1 = input("What do you want: ");
elif input1 == "weather":
input3 = input("Set the weather: ");
wea=input3;
input1 = input("What do you want: ");
elif input1 == "temperature":
input4 = input("Set the temperature: ");
temp=input4;
input1 = input("What do you want: ");
elif input1 == "commands":
print ("Commands: ");
print ("day");
print ("weather");
print ("temperature");
input1 = input("What do you want: ");
else:
print ("Unknow Command! Try the commmand \"commands\".");
input1 = input("What do you want: ");
は、コードの最初の行を再実行します何の制御構造がありません。ループを調べてください。これは 'while'ループのように見えます。 –
コードをループに入れて繰り返す必要があるようです。例えば。 while(input1!= "exit"): ... –