From 0fdcb88f2c826c13bd1d962370be07dc6a76bedf Mon Sep 17 00:00:00 2001 From: tridibbasak21 <67741756+tridibbasak21@users.noreply.github.com> Date: Wed, 15 Jul 2020 20:43:06 +0530 Subject: [PATCH] Create list.py --- list.py | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 list.py diff --git a/list.py b/list.py new file mode 100644 index 0000000..00c15cc --- /dev/null +++ b/list.py @@ -0,0 +1,51 @@ +# Online Python compiler (interpreter) to run Python online. +# Write Python 3 code in this online editor and run it. + +list=[1,2,3,4,5,6,"Anmol","Anshu","Tridib","muskan","ankit","komal"] +# A list is an ordered sequence that can be indexed, sliced + +#declare +list1=[1,"B","C",22] +print(list1) +#update +list1[1]=7 +# while updating, data type doesnt matter +print(list1) +#del +del list1[2] +print(list1) +#concat +list2=["tom",10,"fluffy"] +list3=["bella",3,"angry"] +listcomb=list2+list3 +print(listcomb) + +#multiply +#with string, multiply is actually repetition +#basic with integer +print(list2[1]*3) +print(list2*2) + +#slicing in list +print(len(list)) +print(list) +val="komal_Anshu" +print(val[-1:]) +print(list[-1:]) +print(list[2:5]) +print(list[-10:-1]) + +# traversing around the list +for x in list2: + print(x) + +list=[1,2,7,3,4,5,6,3,4,5,6,5] +print(list) +del list[2] +print(list) + + + + + +