How to use 'python create a list from 1 to n' in Python

Every line of 'python create a list from 1 to n' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your Python code is secure.

All examples are scanned by Snyk Code

By copying the Snyk Code Snippets you agree to
47def make_tuple(x, n):
48 if is_sequence(x):
49 return x
50 return tuple([x for _ in range(n)])
13def _integers_from(n):
14 """
15 Returns a generator for the integers starting at n.
16
17 EXAMPLES::
18
19 sage: from sage.combinat.species.stream import _integers_from
20 sage: g = _integers_from(5)
21 sage: [g.next() for i in range(5)]
22 [5, 6, 7, 8, 9]
23 """
24 while True:
25 yield n
26 n += 1

Related snippets