Concatenation<\/strong><\/p>\nList concatenation can be carried out using the + operator.<\/p>\n
>>> [ 1 , 2 , 3 ] +[ ' hi ' , ' hello ' ]\r\n[ 1 , 2 , 3 , ' hi ' , ' hello ' ] ;<\/pre>\nRepetition<\/strong><\/p>\nThe * operator can be used to carry out repetition operations.<\/p>\n
>>> [ ' Hey ' ] *3 \r\n[ ' Hey ' , ' Hey ' , ' Hey ' ]<\/pre>\nMembership operation<\/strong><\/p>\nThe list also supports membership operation i.e. checking the existence of an element in a list.<\/p>\n
>>> 4 in [ 6 , 8 , 1 , 3 , 5 , 0 ]\r\nFalse \r\n>>> 1 in [ 6 , 8 , 1 , 3 , 5 , 0 ]\r\nTrue<\/pre>\nSlicing operation<\/strong><\/p>\nAs list is a sequence, so indexing and slicing work the same way for list as they do for strings. All slice operations return a new list containing the requested elements:<\/p>\n
>>> a= [ ' spam ' , ' eggs ' , 100 , 1234 ]\r\n>>> a [ 2 ] \r\n100\r\n>>> a [ -2 ]\r\n100\r\n>>> a [ 1 : 3 ] \r\n[ ' eggs ' , 100 ]\r\n>>> a [ : ]\r\n[ ' spam ' , ' eggs ' , 100 , 1234 ]<\/pre>\nList slicing can be in form of steps, the operation s [ i: j: k ] slices the list s from i to j with step k.<\/p>\n
>>> squares=[ x**2 for x in range ( 10 ) ] \r\n>>> squares\r\n[ 0 , 1 , 4 , 9 , 16 , 25 , 36 , 49 , 64 , 81 , 100 , 121 , 144 , 169 , 196 ]\r\n>>> squares [ 2 : 12 : 3 ]\r\n[ 4 , 25 , 64 , 121 ]<\/pre>\nSlice indices have useful defaults, an omitted first index defaults to zero, an omitted second index defaults to the size of the list being sliced.<\/p>\n
>>> squares= [ x**2 for x in range ( 10 ) ]\r\n>>> squares \r\n[0 , 1 , 4 , 9 , 16 , 25 , 36 , 49 , 64 , 81 , 100 , 121 , 144 , 169 , 196 ]\r\n>>> squares [ 5 : ]\r\n[ 25 , 36 , 49 , 64 , 81 , 100 , 121 , 144 , 169 , 196 ]\r\n>>> squares [ : 5 ]\r\n[ 0 , 1 , 4 , 9 , 16 ]<\/pre>\n","protected":false},"excerpt":{"rendered":"In this Page, We are Providing Python Programming \u2013 Some List Operations. Students can visit for more Detail and Explanation of Python Handwritten Notes\u00a0Pdf. Python Programming \u2013 Some List Operations Some list operations Some of the list operations supported by Python are given below. Concatenation List concatenation can be carried out using the + operator. …<\/p>\n
Python Programming \u2013 Some List Operations<\/span> Read More »<\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"spay_email":"","jetpack_publicize_message":"","jetpack_is_tweetstorm":false,"jetpack_publicize_feature_enabled":true},"categories":[5],"tags":[],"yoast_head":"\nPython Programming \u2013 Some List Operations - Python Programs<\/title>\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n\t \n\t \n\t \n