codes = ["A", "B", "C", "D", "E"]
random.shuffle(codes)
def print_message(message):
print "\n"
print "-"*10
print message
print "-"*10
print "\n"
print_message('This is a test of the %s system' % codes[0])
次に、提示されたランダムな文字に基づいて print_message('This... ') の結果に対して if ステートメントを実行するにはどうすればよいですか。
例。コード[0]の結果がprint_message()の「A」になった場合、これが画面に表示されます。
----------
This is a test of the A system.
The A system is really great.
---------
コマンドをさらに数回実行すると、次のように表示されます。
----------
This is a test of the C system.
The C system sucks.
----------
----------
This is a test of the B system.
The B system has improved greatly over the years.
----------