python初学者问个小问题

为啥这段没有打印出任何结果啊?

users = []
for user in users:
if user == 'admin':
print("He is here.")
else:
print("We need to find some users!")

还有大家的代码怎么粘上去的?能左右滑动。

因为你的users是空的,循环里面不会被执行,可以修改:

users = ['admin', 'root']
for user in users:
    if user == 'admin':
        print("He is here.")
    else:
        print("We need to find some users!")

至于你说的代码,你在编辑的时候,可以看到编辑框的右上侧有一个 </> 按钮,那个可以定义代码区域

img

您好,我是有问必答小助手,您的问题已经有小伙伴帮您解答,感谢您对有问必答的支持与关注!
PS:问答VIP年卡 【限时加赠:IT技术图书免费领】,了解详情>>> https://vip.csdn.net/askvip?utm_source=1146287632