[Solved] python: how can i create a list of integers,to a number? [closed]


numbers = list(range(k+1))   # For Python 2, it is just range(k+1).

Given an integer k, which you can get with input.

The range creates an iterator (in Python 3) with those numbers (k+1 because it is not inclusive, but you need it to be), then we make it into a list.


Demo:

>>> k = int(input())
16
>>> numbers = list(range(k+1))
>>> numbers
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]

5

solved python: how can i create a list of integers,to a number? [closed]