Basic stuff using Lists

Kasinath Reddy
2 min readJun 14, 2020

Basics about list data structure in python

Topics:

  1. Indexing and slicing
  2. Looping
  3. Basic star pattern
  4. List comprehension
  5. usage of lambdas coupled with map,filter,reduce

Indexing and slicing

Indexing is used to access elements at particular index position from your list where as slicing can be used to get elements between two particular index positions

Loops

We will discuss only about for loop for now

Google about usage of continue,pass,break statements and loops are powerful when you need iterate and check for multiple conditions.

Basic star pattern

Pattern problems solving will improve your logical ability and looping logic this pattern might look simple but you can attempt some complex pattern problem

List comprehension

For basic list operations comprehensions comes in handy writing complex comprehension will reduce code readability

Usage of lambdas coupled with map,filter,reduce

Map will be applied on all and it will return None if the condition is not satisfied whereas filter only returns element if condition is satisfied

map,filter will be useful especially with lambdas for minimal logic stuff

For reduce you have to import it by using below command

from functools import reduce

Reduce does operation and two elements and output is a single element for good explanation please google it out we will see reduce uses with nested list example

The more you practice the more better you can use all of this stuff and if you liked the article like and share

#Happy learning

--

--