程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
您现在的位置: 程式師世界 >> 編程語言 >  >> 更多編程語言 >> Python

A little question for Python beginners

編輯:Python

Why doesn't this paragraph print out any results ?

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

And how the code is pasted ? Can slide left and right .




Take the answer :

Because of you. users It's empty. , The loop will not be executed , You can modify :

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

As for your code , When you were editing , You can see that there is a... On the upper right side of the edit box </> Button , That can define code regions



  1. 上一篇文章:
  2. 下一篇文章:
Copyright © 程式師世界 All Rights Reserved