为什么该程序的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()
因为您要返回一个元组。尝试返回一个字符串。
return "The age of the oldest child is {}".format(age_of_oldest)
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句