-2

次のコードを検討してください。

i=0
while i<5:
    print(i, end=" ")
    i = i + 1

出力は次のようになります。

0 1 2 3 4

1 2 3 4 の前に文字列「結果」を追加したい場合、出力が期待されます: 結果 1 2 3 4 (同じ行)。どの組み込み関数を使用すればよいですか?

4

1 に答える 1

2
i = 0
print('the result', end=' ') # begin line with 'the result'
while i < 5:
    print(i, end=' ')
    i = i + 1
print()  # move to next line
于 2013-09-17T20:52:43.887 に答える