Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the name for [x for x in some_list] type of construct in python? [duplicate]

Tags:

python

Couldn't really find it, but probably it's me not knowing how to search properly :(

Just wanted to find out what the name is for:

[x for x in some_list]

type of construct?

like image 945
rytis Avatar asked Jan 20 '10 14:01

rytis


People also ask

What X for X means in Python?

This is just standard Python list comprehension. It's a different way of writing a longer for loop. You're looping over all the characters in your string and putting them in the list if the character is a digit.

What does X and Y mean in Python?

It means that the function you have called returns an iterable, and the index 0 of the iterable is assigned to x and the index 1 is assigned to y.


1 Answers

It's a list comprehension

like image 117
Kenan Banks Avatar answered Nov 14 '22 23:11

Kenan Banks