Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

What is the shortest way to create the list [0, 2, 3, …, 234] in python?

I want to create the list [0, 2, 3, …, 234] in python, possibly within a row and without listing all numbers explicitly

I know that following code works:

list1 = [0]
for i in range(2,235):
    list1.append(i)

But are there any possibilities to finish that within a row?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

list1 = [0] + list(range(2,235))

list will expand a lazy enumerator.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading