Strip (RM) is used to delete white space characters within an element:
RM corresponds to the element for which you want to remove whitespace, and when RM is empty (strip ()), the whitespace of all elements is removed
StartsWith, endswith the element used to find the beginning or end condition
Example:
1Li = ["Alec","Aric","Alex","Tony","Rain"]2Tu = ("Alec","Aric","Alex","Tony","Rain") 3DIC = {'K1':"Alex",'K2':'Aric',"K3":"Alex","K4":"Tony"}4 forIinchLi:5b =I.strip ()6 if(B.startswith ("a")orB.startswith ("A")) andB.endswith ("C"):7 Print (b)8 9 forIinchTu:Tenb =I.strip () One if(B.startswith ("a")orB.startswith ("A")) andB.endswith ("C"): A Print (b) - - forIinchDIC: theb =Dic[i].strip () - if(B.startswith ("a")orB.startswith ("A")) andB.endswith ("C"): - Print (b
The above code: finds all elements that start with a or a and ends with C, and outputs
Output Result:
Alecaricalecaricaric
Python in Strip, StartsWith, EndsWith