print (message_2.capitalize())
の後に出力が\n
でない場合に結果に新しい行を強制するのはなぜですか?メソッドが大文字にされた後に予期しない改行が発生する
# Input example python script
# Apparently in python 3.6, inputs can take strings instead of only raw values back in v2.7
message_0 = "good morning!"
message_1 = "please enter something for my input() value:"
message_2 = "the number you entered is ... "
message_3 = "ok, now this time enter value for my raw_input() value:"
message_final1 = "program ended."
message_final2 = "thank you!"
print ("\n\n")
print (message_0.capitalize() + "\n")
input_num = input(message_1.capitalize())
print ("\n")
# This line is obsoleted in python 3.6. raw_input() is renamed to input() .
# raw_input_num = raw_input(message_3.capitalize())
# data conversion
print ("Converting input_num() variable to float...\n")
input_num = float(input_num)
print ("\n")
print (message_2.capitalize())
print (input_num)
print ("\n")
print (message_final1.capitalize() + " " + message_final2.capitalize())
次のように出力されている:
Good morning!
Please enter something for my input() value:67.3
Converting input_num() variable to float...
The number you entered is ...
67.3
Program ended. Thank you!