1
423views
What is list comprehension? explain with example.
1 Answer
2
5views

Solution

List Comprehension

  • list comprehension offer a way to create lists based on existing iterable. When using list comprehension, lists can be built by using ant iterable , including strings, list, tuple.

ex: (using for loop)

input :

       mystr = 'ques'
       mylist = [ ]
       for c in my str: …

Create a free account to keep reading this post.

and 2 others joined a min ago.

Please log in to add an answer.