python生成1到100的列表_Python3基础 list 推导式 生成100以内的偶数列表

Python : 3.7.0

OS : Ubuntu 18.04.1 LTS

IDE : PyCharm 2018.2.4

Conda : 4.5.11

typesetting : Markdown

code

coder@Ubuntu:~$ source activate py37

(py37) coder@Ubuntu:~$ ipython

Python 3.7.0 (default, Jun 28 2018, 13:15:42)

Type 'copyright', 'credits' or 'license' for more information

IPython 6.5.0 -- An enhanced Interactive Python. Type '?' for help.

In [1]: test = [each for each in range(100) if not (each % 2 == 1)]

In [2]: test

Out[2]:

[0,

2,

4,

6,

8,

10,

12,

14,

16,

18,

20,

22,

24,

26,

28,

30,

32,

34,

36,

38,

40,

42,

44,

46,

48,

50,

52,

54,

56,

58,

60,

62,

64,

66,

你可能感兴趣的:(python生成1到100的列表_Python3基础 list 推导式 生成100以内的偶数列表)