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

Python list derivation

編輯:Python
# List derivation 
l1 = [i for i in range(1, 101)]
print(l1)
l2 = [i ** 2 for i in range(1, 11)]
print(l2)
l3 = [f'{
i} Number ' for i in range(1, 11)]
print(l3)
l4 = [i for i in range(1, 21) if i != 18]
print(l4)
# Through the list test Build a new list , Not included 4
test = [[5, 6, 9, 4], [4, 7, 8, 10]]
new = [j for i in test for j in i if j != 4]
print(new)
# 100 Can be 7 Divisible number 
l5 = [i for i in range(1, 101) if i % 7 == 0]
print(l5)

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