为什么这个程序的return
语句用括号和引号输出答案?
示例输出:('The age of the oldest child is', 6)
虽然当我使用print
语句而不是return
时,格式化是否正确?
带有print语句的示例输出:The age of the oldest child is 6
def ageOfOldest():
age_youngest = input("Enter the age of the youngest child: ")
age_middle = input("Enter the age of the middle child: ")
age_of_oldest = (age_middle - age_youngest) + age_middle
return "The age of the oldest child is ", age_of_oldest
print ageOfOldest()
答案 0 :(得分:0)
因为你正在返回一个元组。请尝试返回字符串。
return "The age of the oldest child is {}".format(age_of_oldest)