<jupyter_start><jupyter_text>Making List and Printing List<jupyter_code>#this ismy list
mylist =[4,5,7,9,20]

#this will print the list
print(mylist)<jupyter_output>[4, 5, 7, 9, 20]<jupyter_text>Check the length of the list<jupyter_code># This will check and inform the length of the list  mylist = ["apple", "banana", "cherry"]
print(len(mylist))<jupyter_output>5<jupyter_text>Printing The vales from the list<jupyter_code># thiswill tell the type of the list 
Hellolist = ["apple", "banana", "cherry"]
print(type(Hellolist))<jupyter_output><class 'list'><jupyter_text>Access Data From List<jupyter_code># You can access the elements from the list
# index value matter if greater then it will through an error
rafaylist= [10,50,69,78,90]
#print(rafaylist[2])
print(rafaylist[4])s<jupyter_output>90<jupyter_text>Negative IndexingNegative indexing means start from the end-1 refers to the last item, -2 refers to the second last item etc.<jupyter_code>thislist = ["apple", "banana", "cherry"]
print(thislist[-1])<jupyter_output>cherry<jupyter_text>Range From the IndexThis will tell us about the range of the list from the starting point to the end point<jupyter_code>rafaylist2 = ["Saqib", "Saima", "Moeez", "Muqeet", "Rafay", "Kashif", "Shazia"]
print(rafaylist2[0:6])<jupyter_output>['Saqib', 'Saima', 'Moeez', 'Muqeet', 'Rafay', 'Kashif']<jupyter_text>Check for some Items in the listIn this we shall check if an item is present in the list or not if the item is not installed then it will show an error<jupyter_code>rafaylist = ["Rafay","Moeez","Muqeet"]
if "Saqib" in Rafaylist:
    print("Yes,'Rafay' is in the fruits list")
else:
    print("The Word is not aviable in the list")
# Rafaylist = ["Rafay", "Moeez", "Muqeet"]
# if "Ssqib" in rafaylist:
#       print("Yes, 'Saqib' is in the fruits list")<jupyter_output>The Word is not aviable in the list<jupyter_text>Change the values in the IndexThis will change the value in the list at the given index<jupyter_code>rafaylist =[ 56,89,90,89,67,66]
rafaylist[1]= 67
print(rafaylist)<jupyter_output>[56, 67, 90, 89, 67, 66]<jupyter_text>Changing the values using RangeIn this we will replace the compoents of the list with the range, the value in the ranger will be chaged only as shown in the example bellow<jupyter_code>thislist = ["apple", "banana", "cherry", "orange", "kiwi", "mango"]
thislist[1:3] = ["blackcurrant", "watermelon"]
print(thislist)<jupyter_output>['apple', 'blackcurrant', 'watermelon', 'orange', 'kiwi', 'mango']<jupyter_text>In case of less values:If you insert less items than you replace, the new items will be inserted where you specified, and the remaining items will move accordingly:<jupyter_code>thislist = ["apple", "banana", "cherry"]
thislist[1:3] = ["watermelon"]
print(thislist)<jupyter_output>['apple', 'watermelon']<jupyter_text>Insert Values:You can add an element in the list using the insert command in the list<jupyter_code>Rafaylist = ["Saqib", "Saima", "Chess"]
Rafaylist.insert(2, "Moeez")
print(Rafaylist)<jupyter_output>['Saqib', 'Saima', 'Moeez', 'Chess']<jupyter_text>Join ListThere are different ways to join two more more then two list, You can join using function or using for loop as well.   1) Simple Way Joinning List In this we use plus sign to combine lists<jupyter_code>family1=["Saqib", "Saima"]
family2= ["rafay","Moeez","Muqeet"]

list3= family1 + family2
print(list3)<jupyter_output>['Saqib', 'Saima', 'rafay', 'Moeez', 'Muqeet']<jupyter_text>2) Joining using Append functionIn this we will be using the append() function and this function will help you to join list, but for append function we can use for loop<jupyter_code>family1=["Saqib", "Saima"]
family2= ["Rafay","Moeez","Muqeet"]

for x in family2:
    family1.append(x)
print(family1)<jupyter_output><empty_output>
StarcoderdataJupyterStructuredCleanDedup