如果输入= list [n]:我该如何设置?

时间:2019-02-05 02:00:52

标签: python list if-statement printing

我总是在线路上输入错误,但是我不确定如何解决。 对不起,如果格式不正确。

这是在python 2.6上

videoGames = ["Fortnite", "Minecraft", "Roblox", "2048", "Mario Cart"]
favGame = raw_input("What is your favorite video game?")
if favGame == videoGames[1]
    print("Hi.")
print("Really?! We both enjoy playing") #add the input that matches with the list

如果用户输入的内容与列表中的一项匹配,那么它将打印“真的?!我们都喜欢玩游戏(游戏)

1 个答案:

答案 0 :(得分:3)

您在此行上缺少一个冒号:

if favGame == videoGames[1]

应该是

if favGame == videoGames[1]:

要打印游戏:

if favGame in videoGames:
    print("Really?! We both enjoy playing", favGame)
相关问题