【发布时间】:2016-06-01 12:35:38
【问题描述】:
我必须创建一个将整数、字符串和布尔值列表作为输入的函数。然后将字符串作为一个句子打印出来。到目前为止,这是我的功能:
def sentenceGenerator(a):
newList = []
for string in a:
if string == str
newList.append(string)
print(newList)
这就是我使用它的方式:
sentenceGenerator(["Mulan", "and", 5, "Aladdin", "is", True, "Quality"])
我知道 if 语句不正确,但我不知道如何搜索。
【问题讨论】:
-
只要使用
is type(string) == str -
你认为这是做什么的:
if string == str? -
哈哈我不知道我是新人,不知道是什么。