基本的东西,我收到了一个语法错误。如何在打印行的末尾添加句点?
first_name = raw_input("Enter your first name: ")
last_name = raw_input("Enter your last name: ")
print "Enter your date of birth"
month= raw_input("Month? ")
day= raw_input("Day? ")
year= raw_input("Year? ")
print "Here's your information"
print first_name, "was born on", month, day+',', year.
答案 0 :(得分:4)
你需要连接它:
print first_name, "was born on", month, day+',', year, "."
更新:正如@ sr2222指出的那样,这将在句号之前打印一个额外的空格。如果你想避免它(并假设年份是一个字符串):
print first_name, "was born on", month, day+',', year + "."
答案 1 :(得分:1)
在它周围加上引号。
print first_name, "was born on", month, day+',', year +'.'
尽管如此,你应该清理它,因为在一行中组合一堆不同的字符串连接机制变得难以阅读。
print first_name + " was born on " + month + ", " + day + ", " + year + "."