清单验证产生不正确的结果

时间:2019-01-28 17:24:55

标签: python

aArtsitNames = ["Artist Name: \"TwnetyOnePiloits\" "],["Artist Name: \"Bastile\" "]

aSongNamesBlanks = ["R___" ],["B__ N____"]

aSongNames = ["Ride"],["Bad News"]


print( aArtsitNames [0] )
print( aSongNamesBlanks [0] )

nUserAnswer = input("Enter the song name: ")

if nUserAnswer == aSongNames[0]:
    print ("correct")

它具有更多组件,但我将其简化了以使其正常运行。 谁能帮我解决为什么不起作用?

2 个答案:

答案 0 :(得分:1)

您没有正确创建列表。您实际上是在创建列表列表。要创建字符串列表,正确的语法应为:

aArtsitNames = ["Artist Name: \"TwnetyOnePiloits\" ", "Artist Name: \"Bastile\" "]

aSongNamesBlanks = ["R___" , "B__ N____"]

aSongNames = ["Ride", "Bad News"]


print( aArtsitNames [0] )
print( aSongNamesBlanks [0] )

nUserAnswer = input("Enter the song name: ")

if nUserAnswer == aSongNames[0]:
    print ("correct")

答案 1 :(得分:0)

您没有创建列表。 尝试

"multiline": "never"