Python for Rubyists, Part III: List Comprehensions

my_list = []print(my_list)
my_list = []for i in range(10):
my_list.append(i)
print(my_list)
my_list = [i for i in range(10)]print(my_list)
my_list = []for i in range(10):
if i % 2 == 0:
my_list.append(i)
print(my_list)
my_list = [i for i in range(10) if i % 2 == 0]print(my_list)

--

--

--

Software developer and science/tech writer. Python, Ruby on Rails, JavaScript, React/Redux, Java. Fascinated by the amazing stories behind today’s tech.

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

A Deep Dive Into DatePicker In Flutter

Coexisting VMWare Workstation with Hyper-V

{UPDATE} Mahtava vuoristorata peli Fun teemapuisto Frenzy Vapaa Hack Free Resources Generator

How to install mhddfs in Centos7

MY HACKBIO BIOINFORMATICS INTERNSHIP EXPERIENCE

Getting Started with the InfluxDB Go Client

REST API Test Framework for Humans by Plain Text Files

Capture and forward correlation IDs through different Lambda event sources

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Alyssa Lerner First

Alyssa Lerner First

Software developer and science/tech writer. Python, Ruby on Rails, JavaScript, React/Redux, Java. Fascinated by the amazing stories behind today’s tech.

More from Medium

Reversing part of a string in Python

Object and Class Attributes in Python Object-Oriented Programming

Writing a shell in python

Imports in Python