为什么我的其他语法无效

时间:2018-09-12 19:23:26

标签: python if-statement

name=input ("please enter your name") .upper() 
names=["MARTIN","JAMES","LOUIS","BABYSHARK"]

if name==list:names
print ("You are allowed to play my game")
else
    prin ("ACCES DENIED!"))

2 个答案:

答案 0 :(得分:5)

您的解决方案可能就是这个:

names=["MARTIN","JAMES","LOUIS","BABYSHARK"]
name = input('Enter your name:').upper()

if name in names:
    print('You can play my game')
else:
    print('Access Denied')

答案 1 :(得分:2)

您需要在if和else语句之后添加冒号。另外,您还需要在if段中缩进代码。