为什么els的语法无效

2024-09-26 22:07:44 发布

您现在位置:Python中文网/ 问答频道 /正文

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!"))

Tags: nameyouinputyourifnamesupperlist
3条回答

您的解决方案可能是:

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')

欢迎使用堆栈溢出。我建议你读the python documentation about if statements。这清楚地定义了语法。最常见的漏掉的是在你的ifelse之后的冒号。你知道吗

您需要在if和else语句后添加冒号。您还需要缩进if段中的代码。你知道吗

相关问题 更多 >

    热门问题