【发布时间】:2021-06-27 20:23:19
【问题描述】:
def city_country(city, country):
message = print(f"{city} is in the {country}! ")
return message
city_n = input("What is the city called? ")
country_n = input("Where is it located? ")
final_message = city_country(city_n , country_n)
print(final_message)
它不应该给我 None 。我做错了吗?
【问题讨论】:
-
第2行:变量
message是函数print的返回值。但是print会返回None,所以你会得到None。 -
print函数没有返回任何东西,所以你得到的是None -
你想要
input()函数,而不是print()函数:) -
@khuynh 很好,它返回
None -
@juanpa.arrivillaga 隐式无 d:
标签: python