<jupyter_start><jupyter_text>List in Python>  **List is one of the collection data types than can contain multiple values in an ordered sequence and are mutable unlike String.**  - List is one of the collection data type. - List consists of sequence like tuple and range- Sequence : Meaning they have indices, can also be reffered to as ordered- Mutable : Meaning the values can be updated or modified unlike in the String data type which are immutable- List defined with the square brackets. All the values are comma separated like array in other language and enclosed by square brackets(```["value1",1,[1,2,3,4],True]```)- Here the values can be any values of any data types<jupyter_code>#Strings are immutable
stringtype = "Hello"
stringtype[0]
#Python generates id for each object
print(id(stringtype))

#generates error
#stringtype[0] = "E"

stringtype = "Hi"
print(id(stringtype))
#Defining a list
list_of_datatype_values = ["First",True,[1,2,3,4,5,6,7,8,9,0],"LastValue"]
print(list_of_datatype_values)<jupyter_output>['First', True, [1, 2, 3, 4, 5, 6, 7, 8, 9, 0], 'LastValue']<jupyter_text>Fetch the value To fetch a specific value from a list we can use the index of that item. Please note that the index starts from Zero (0). Index can be positive or negative.- Positive index : Starts from left of the list and starts from 0- Negative index : Starts from right of the list and starts from -1<jupyter_code>#get 3rd item i.e of 2nd index
print('Value of {index} index is {value}'.format(index=2,value=list_of_datatype_values[2]))
print('Data type of the 2nd index is {DataType}'.format(DataType=type(list_of_datatype_values[2])), end="\n\n")

#Negative Index
negative_1_item = list_of_datatype_values[-1]
print("-1 index value is",negative_1_item)<jupyter_output>Value of 2 index is [1, 2, 3, 4, 5, 6, 7, 8, 9, 0]
Data type of the 2nd index is <class 'list'>

-1 index value is LastValue<jupyter_text>List slicing or Range of items from listLike the slicing in the String data type same can be done in the List Data Type.  Here the slicing returns new list of items from the specified range of indexes from a given list.eg:```list_name[:]```- start_index :      - this could positive or negative whole number    - values from this position / index will be fetched    - blank start_index will return all the values from the begining- end_index    - could be positive or negative whole number    - **note that the the value of this index is not included**    - value must always be greater than the start_index    - when left blank will return all the values to the end<jupyter_code>#list of known nicknames 
nick_names = ["<NAME>","Matey","Lale","Don","<NAME>","Daa","Bhaa"]

#Get the list of values from 1st index to the 3rd index
print(nick_names[1:4])

#Negative Indexing
print(nick_names[-5:-4])

#Blank start_index
print(nick_names[:2])

#Blank start_index and negative end_index
print(nick_names[:-2])


#Blank end_index
print(nick_names[3:])

#Blank end_index and negative start_index
print(nick_names[-3:])

#both blank
print(nick_names[:])

#last element
print(nick_names[6:])<jupyter_output>['Matey', 'Lale', 'Don']
['Lale']
['<NAME>', 'Matey']
['<NAME>', 'Matey', 'Lale', 'Don', '<NAME>']
['Don', '<NAME>', 'Daa', 'Bhaa']
['<NAME>', 'Daa', 'Bhaa']
['<NAME>', 'Matey', 'Lale', 'Don', '<NAME>', 'Daa', 'Bhaa']
['Bhaa']<jupyter_text>Check for MUTABILITYThe Corona Story<jupyter_code>#The corona virus story
#list of human corona virus
#link : https://en.wikipedia.org/wiki/Coronavirus#Classification
human_corona_virus = ["MERS","SARS"]
print(human_corona_virus)


#But the values has "-CoV" at the end, so lets edit
human_corona_virus[0] = human_corona_virus[0]+"-CoV"
human_corona_virus[1] = human_corona_virus[1]+"-CoV"
print(human_corona_virus)


#And in 2019 new Human Corona virus was introduced so we have add this into the list.. but how ?
human_corona_virus.append("Coronavirus")
print(human_corona_virus)


#But the name is generic, as this name was introduced for the first time so lets remove and then add COVID-19 in the second index
human_corona_virus.remove("Coronavirus")
print(human_corona_virus)
human_corona_virus.insert(2,"COVID-19")
#print(human_corona_virus)


#So now there are three types of human corona viruses
print(len(human_corona_virus))


#All of the humans in the world now just want to remove the latest corona virus ( COVID-19) like POP and everyone be normal
human_corona_virus.pop()
print(human_corona_virus)


#But it was just a dream and per scientists and many health authorities it will be there 
human_corona_virus.append("COVID-19")
print(human_corona_virus)


#Many people are being diagnosed by PCR and RDT method to check for the virus existense
"COVID-19" in human_corona_virus


# if true they were kept in quarantine else sent home and stay safe
patient_viruses = ["RHINO"]
if human_corona_virus[2] in patient_viruses:
    print("QUARANTINE !!!")
else:
    print("Go Home and Stay Safe")


#Many scientists and researchers are studying the COVID-19 virus to create vaccines and many has been developed
vaccines = ["vaccine 1","vaccine 2","vaccine 3"]
print(vaccines)


#But Trump suggests Hydrochloroquine is effective for now 
vaccines.append("Hydrochloroquine")
print(vaccines)


#But many says its not the vaccines so they removed it from the vaccine
del vaccines[3]
print(vaccines)


#Whole world is looking for vaccines and the test is  on-going. if the test will successfull then the demand will be show high that the list could be empty
vaccines.clear()
print(vaccines)


#but if the test fails then the vaccines could be removed as a whole
del vaccines
print(vaccines)


#There is also chance that the chemical formula can be copied from another vaccines
vaccine1 = ["element1","element2","element3","element4"]
print(vaccine1)
vaccine2 = vaccine1.copy()
print(vaccine2)


#and add another list of chemicals to create new one
vaccine2 = vaccine2 + ["element5","element6"]
print(vaccine2)


#or join another chemicals to make another vaccine
vaccine3 = vaccine1 +vaccine2
print(vaccine3)<jupyter_output>['element1', 'element2', 'element3', 'element4', 'element1', 'element2', 'element3', 'element4', 'element5', 'element6']<jupyter_text>dir() function> Gives the available methods<jupyter_code>dir(vaccine3)

help(vaccine3.sort)
vaccine3.__sizeof__()
#Reference Type demo
list1 = [1,2,3,4,5]
list2 = list1.copy()
print(id(list1))
print(id(list2))
list2.append("Hello")
print(list1)
print(list2)<jupyter_output>2198372702528
2198372511360
[1, 2, 3, 4, 5]
[1, 2, 3, 4, 5, 'Hello']
{'fraction_non_alphanumeric': 0.10854961832061069, 'fraction_numerical': 0.026106870229007633, 'mean_word_length': 5.623862487360971, 'pattern_counts': {'":': 0, '<': 26, '<?xml version=': 0, '>': 28, 'https://': 1, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '5', 'dir': 'jupyter-structured-clean-dedup', 'id': '153332', 'license': 'MIT', 'n_tokens_mistral': 2268, 'n_tokens_neox': 2102, 'n_words': 797, 'path': 'Basics/Python_List.ipynb', 'repo_name': 'suraj-shakya/learning_python', 'size': '6600'}