【发布时间】:2016-01-23 23:06:58
【问题描述】:
我对编码很陌生,所以我希望我的问题有意义/格式正确。
这是我的代码:
#this function takes a name and a town, and returns it as the following:
#"Hello. My name is [name]. I love the weather in [town name]."
def introduction("name","town"):
phrase1='Hello. My name is '
phrase2='I love the weather in '
return ("phrase1" + "name" + "phrase2" + "town")
例如python shell 中的introduction("George","Washington") 将返回为"Hello. My name is George. I love the weather in Washington."
我的问题是我的代码没有这样做。相反,我收到以下错误:
Invalid syntax: <string> on line 1". In Wing101 **,"town"):
下面有一个红色的摆动。我不确定我做错了什么......我知道“name”和“town”是字符串而不是变量,但我真的不知道如何解决它。
感谢任何帮助/cmets。
【问题讨论】:
-
我建议你对如何定义函数做一些基础研究,比如阅读the relevant section in the official tutorial。
-
会做的,谢谢。
标签: python python-2.7 syntax