SlideShare a Scribd company logo
1 of 15
G H PATEL COLLEGE OF ENGINEERING &
TECHNOLOGY, V. V. NAGAR,
ACADEMIC YEAR: 2019-20 (EVEN SEM)
CLASS: FINAL YEAR COMPUTER ENGINEERING
2180711-PYTHON PROGRAMMING
BY:
160110107031, NARSINGANI AMISHA
BATCH: 1B07
Presentation Topic:
Strings in Python
WHAT ARE STRINGS?
• STRINGS ARE ARRAYS OF BYTES REPRESENTING UNICODE CHARACTERS.
• PYTHON DOES NOT HAVE A CHARACTER DATA TYPE, A SINGLE
CHARACTER IS SIMPLY A STRING WITH A LENGTH OF 1.
• SQUARE BRACKETS CAN BE USED TO ACCESS ELEMENTS OF THE STRING.
• STRINGS IN PYTHON CAN BE CREATED USING SINGLE QUOTES OR DOUBLE
QUOTES OR EVEN TRIPLE QUOTES.
• FOR EXAMPLE:
STRING1 = ‘WELCOME TO THE GCET WORLD’
STRING2 = “WELCOME EVERYONE!”
STRING 3 = '''I'M A GEEK AND I LIVE IN A WORLD OF "GEEKS"'''
ITERATING THROUGH STRINGS
• USING FOR LOOP WE CAN ITERATE THROUGH A STRING.
ACCESSING INDIVIDUAL CHARACTERS
• WE CAN ACCESS INDIVIDUAL CHARACTERS OF STRING USING INDEXING.
• INDEXING ALLOWS NEGATIVE ADDRESS REFERENCES TO ACCESS
CHARACTERS FROM THE BACK OF THE STRING, E.G. -1 REFERS TO THE
LAST CHARACTER, -2 REFERS TO THE SECOND LAST CHARACTER AND SO
ON. (SEE THE BELOW FIGURE)
• WHILE ACCESSING AN INDEX OUT OF THE RANGE WILL CAUSE
AN INDEXERROR.
P R O G R A M M I N G
0 1 2 3 4 5 6 7 8 9 10
-11 -10 -9 -8 -7 -6 -5 -4 -3 -2 -1
ACCESSING INDIVIDUAL CHARACTERS
STRING1=“PROGRAMMING”
PRINT("INITIAL STRING: ")
PRINT(STRING1)
PRINT("NFIRST CHARACTER OF STRING IS: ")
PRINT(STRING1[0]) #OUTPUT: P
PRINT("NLAST CHARACTER OF STRING IS: ")
PRINT(STRING1[-1]) #OUTPUT: G
STRING SLICING
• TO ACCESS A RANGE OF CHARACTERS IN THE STRING, METHOD OF SLICING IS
USED.
• SLICING IN A STRING IS DONE BY USING A SLICING OPERATOR (COLON).
• WE CAN ACCESS SUBSTRINGS USING SLICING
• FOR EXAMPLE:
C=“PROGRAMMING IS GOOD“
PRINT(C)
D=C[5:7]
PRINT(D) #OUTPUT: AM
E=C[12:14]
PRINT(E) #OUTPUT: IS
STRING CONCATENATION
• JOINING OF TWO OR MORE STRINGS INTO A SINGLE ONE IS CALLED
CONCATENATION.
• THE + OPERATOR DOES THIS IN PYTHON.
• THE * OPERATOR CAN BE USED TO REPEAT THE STRING FOR A GIVEN NUMBER OF
TIMES.
• FOR EXAMPLE:
firstname = “Amisha”
lastname = “Narsingani”
fullname=firstname +
lastname
print(fullname)
word=“hello “
echo = word*3
print(echo)
STRINGS ARE IMMUTABLE
• UPDATION OR DELETION OF CHARACTERS FROM A STRING IS NOT
ALLOWED.
• THIS WILL CAUSE AN ERROR BECAUSE ITEM ASSIGNMENT OR ITEM
DELETION FROM A STRING IS NOT SUPPORTED.
• ALTHOUGH DELETION OF ENTIRE STRING IS POSSIBLE WITH THE USE OF A
BUILT-IN DEL KEYWORD.
• THIS IS BECAUSE STRINGS ARE IMMUTABLE, HENCE ELEMENTS OF A STRING
CANNOT BE CHANGED ONCE IT HAS BEEN ASSIGNED. ONLY NEW STRINGS
CAN BE REASSIGNED TO THE SAME NAME.
STRINGS ARE IMMUTABLE
Updating a character:
STRING1 = "HELLO, I'M A GEEK"
PRINT(STRING1)
# UPDATING A CHARACTER OF THE STRING
STRING1[2] = 'P'
PRINT("NUPDATING CHARACTER AT 2ND INDEX: ")
PRINT(STRING1)
#TYPEERROR: ‘STR’ OBJECT DOES NOT SUPPORT ITEM
ASSIGNMENT
DEL STRING1[2]
PRINT("NDELETING CHARACTER AT 2ND INDEX: ")
PRINT(STRING1)
#TYPEERROR: ‘STR’ OBJECT DOESN’T SUPPORT ITEM
DELETION
Updating Entire String:
String1 = "Hello, I'm a Geek"
print(String1)
# Updating a String
String1 = "Welcome to the Geek World"
print("nUpdated String: ")
print(String1)
#doesn’t generate an error and gives output
successfully
del String1
#successfully deletes String1
SPLIT METHOD
• RETURNALIST OF THE WORDS IN STRING
SPLIT SEPARATOR
• DEFAULT SEPARATOR IS ANY SPACE(SPACE,NEWLINE,TAB)
• TO SPECIFY ANY OTHER SEPARATOR, SPECIFY IT EXPLICITLY.
JOIN METHOD
• USED TO EFFICIENTLY CONSTRUCT STRINGS FROM MULTIPLE FRAGMENTS.
STR.JOIN(ITERABLE)
• RETURN A STRING WHICH IS THE CONCATENATION OF THE STRINGS IN ITERABLE.
• A TYPEERROR WILL BE RAISED IF THERE ARE ANY NON-STRING VALUES IN
ITERABLE.
• FOR EXAMPLE:
vowels = ['a', 'e', 'i', 'o',
'u’]
print(vowels)
['a', 'e', 'i', 'o', 'u’]
s = "-".join(vowels)
print(s)
'a-e-i-o-u'
STRINGMETHODS
String methods
Thank You!

More Related Content

What's hot

Data Structures in Python
Data Structures in PythonData Structures in Python
Data Structures in PythonDevashish Kumar
 
Python-03| Data types
Python-03| Data typesPython-03| Data types
Python-03| Data typesMohd Sajjad
 
Conditional and control statement
Conditional and control statementConditional and control statement
Conditional and control statementnarmadhakin
 
python Function
python Function python Function
python Function Ronak Rathi
 
Python Variable Types, List, Tuple, Dictionary
Python Variable Types, List, Tuple, DictionaryPython Variable Types, List, Tuple, Dictionary
Python Variable Types, List, Tuple, DictionarySoba Arjun
 
Python strings presentation
Python strings presentationPython strings presentation
Python strings presentationVedaGayathri1
 
Introduction to Python
Introduction to Python Introduction to Python
Introduction to Python amiable_indian
 
String Manipulation in Python
String Manipulation in PythonString Manipulation in Python
String Manipulation in PythonPooja B S
 
Full Python in 20 slides
Full Python in 20 slidesFull Python in 20 slides
Full Python in 20 slidesrfojdar
 
Variables in python
Variables in pythonVariables in python
Variables in pythonJaya Kumari
 
Strings in Python
Strings in PythonStrings in Python
Strings in Pythonnitamhaske
 
Python dictionary
Python dictionaryPython dictionary
Python dictionarySagar Kumar
 

What's hot (20)

Data Structures in Python
Data Structures in PythonData Structures in Python
Data Structures in Python
 
Python-03| Data types
Python-03| Data typesPython-03| Data types
Python-03| Data types
 
Conditional and control statement
Conditional and control statementConditional and control statement
Conditional and control statement
 
python Function
python Function python Function
python Function
 
Set methods in python
Set methods in pythonSet methods in python
Set methods in python
 
Python exception handling
Python   exception handlingPython   exception handling
Python exception handling
 
Python Variable Types, List, Tuple, Dictionary
Python Variable Types, List, Tuple, DictionaryPython Variable Types, List, Tuple, Dictionary
Python Variable Types, List, Tuple, Dictionary
 
Python strings presentation
Python strings presentationPython strings presentation
Python strings presentation
 
Namespaces
NamespacesNamespaces
Namespaces
 
Introduction to Python
Introduction to Python Introduction to Python
Introduction to Python
 
String Manipulation in Python
String Manipulation in PythonString Manipulation in Python
String Manipulation in Python
 
Full Python in 20 slides
Full Python in 20 slidesFull Python in 20 slides
Full Python in 20 slides
 
Python Scipy Numpy
Python Scipy NumpyPython Scipy Numpy
Python Scipy Numpy
 
Variables in python
Variables in pythonVariables in python
Variables in python
 
Dictionary in python
Dictionary in pythonDictionary in python
Dictionary in python
 
Python set
Python setPython set
Python set
 
Tuples in Python
Tuples in PythonTuples in Python
Tuples in Python
 
Python Flow Control
Python Flow ControlPython Flow Control
Python Flow Control
 
Strings in Python
Strings in PythonStrings in Python
Strings in Python
 
Python dictionary
Python dictionaryPython dictionary
Python dictionary
 

Recently uploaded

Thermal Engineering Unit - I & II . ppt
Thermal Engineering  Unit - I & II . pptThermal Engineering  Unit - I & II . ppt
Thermal Engineering Unit - I & II . pptDineshKumar4165
 
Double Revolving field theory-how the rotor develops torque
Double Revolving field theory-how the rotor develops torqueDouble Revolving field theory-how the rotor develops torque
Double Revolving field theory-how the rotor develops torqueBhangaleSonal
 
A CASE STUDY ON CERAMIC INDUSTRY OF BANGLADESH.pptx
A CASE STUDY ON CERAMIC INDUSTRY OF BANGLADESH.pptxA CASE STUDY ON CERAMIC INDUSTRY OF BANGLADESH.pptx
A CASE STUDY ON CERAMIC INDUSTRY OF BANGLADESH.pptxmaisarahman1
 
HAND TOOLS USED AT ELECTRONICS WORK PRESENTED BY KOUSTAV SARKAR
HAND TOOLS USED AT ELECTRONICS WORK PRESENTED BY KOUSTAV SARKARHAND TOOLS USED AT ELECTRONICS WORK PRESENTED BY KOUSTAV SARKAR
HAND TOOLS USED AT ELECTRONICS WORK PRESENTED BY KOUSTAV SARKARKOUSTAV SARKAR
 
Engineering Drawing focus on projection of planes
Engineering Drawing focus on projection of planesEngineering Drawing focus on projection of planes
Engineering Drawing focus on projection of planesRAJNEESHKUMAR341697
 
Tamil Call Girls Bhayandar WhatsApp +91-9930687706, Best Service
Tamil Call Girls Bhayandar WhatsApp +91-9930687706, Best ServiceTamil Call Girls Bhayandar WhatsApp +91-9930687706, Best Service
Tamil Call Girls Bhayandar WhatsApp +91-9930687706, Best Servicemeghakumariji156
 
Block diagram reduction techniques in control systems.ppt
Block diagram reduction techniques in control systems.pptBlock diagram reduction techniques in control systems.ppt
Block diagram reduction techniques in control systems.pptNANDHAKUMARA10
 
+97470301568>> buy weed in qatar,buy thc oil qatar,buy weed and vape oil in d...
+97470301568>> buy weed in qatar,buy thc oil qatar,buy weed and vape oil in d...+97470301568>> buy weed in qatar,buy thc oil qatar,buy weed and vape oil in d...
+97470301568>> buy weed in qatar,buy thc oil qatar,buy weed and vape oil in d...Health
 
Bridge Jacking Design Sample Calculation.pptx
Bridge Jacking Design Sample Calculation.pptxBridge Jacking Design Sample Calculation.pptx
Bridge Jacking Design Sample Calculation.pptxnuruddin69
 
2016EF22_0 solar project report rooftop projects
2016EF22_0 solar project report rooftop projects2016EF22_0 solar project report rooftop projects
2016EF22_0 solar project report rooftop projectssmsksolar
 
Hazard Identification (HAZID) vs. Hazard and Operability (HAZOP): A Comparati...
Hazard Identification (HAZID) vs. Hazard and Operability (HAZOP): A Comparati...Hazard Identification (HAZID) vs. Hazard and Operability (HAZOP): A Comparati...
Hazard Identification (HAZID) vs. Hazard and Operability (HAZOP): A Comparati...soginsider
 
Learn the concepts of Thermodynamics on Magic Marks
Learn the concepts of Thermodynamics on Magic MarksLearn the concepts of Thermodynamics on Magic Marks
Learn the concepts of Thermodynamics on Magic MarksMagic Marks
 
notes on Evolution Of Analytic Scalability.ppt
notes on Evolution Of Analytic Scalability.pptnotes on Evolution Of Analytic Scalability.ppt
notes on Evolution Of Analytic Scalability.pptMsecMca
 
Online electricity billing project report..pdf
Online electricity billing project report..pdfOnline electricity billing project report..pdf
Online electricity billing project report..pdfKamal Acharya
 
Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...
Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...
Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...Arindam Chakraborty, Ph.D., P.E. (CA, TX)
 
Computer Networks Basics of Network Devices
Computer Networks  Basics of Network DevicesComputer Networks  Basics of Network Devices
Computer Networks Basics of Network DevicesChandrakantDivate1
 
DC MACHINE-Motoring and generation, Armature circuit equation
DC MACHINE-Motoring and generation, Armature circuit equationDC MACHINE-Motoring and generation, Armature circuit equation
DC MACHINE-Motoring and generation, Armature circuit equationBhangaleSonal
 
Standard vs Custom Battery Packs - Decoding the Power Play
Standard vs Custom Battery Packs - Decoding the Power PlayStandard vs Custom Battery Packs - Decoding the Power Play
Standard vs Custom Battery Packs - Decoding the Power PlayEpec Engineered Technologies
 

Recently uploaded (20)

Thermal Engineering Unit - I & II . ppt
Thermal Engineering  Unit - I & II . pptThermal Engineering  Unit - I & II . ppt
Thermal Engineering Unit - I & II . ppt
 
Double Revolving field theory-how the rotor develops torque
Double Revolving field theory-how the rotor develops torqueDouble Revolving field theory-how the rotor develops torque
Double Revolving field theory-how the rotor develops torque
 
A CASE STUDY ON CERAMIC INDUSTRY OF BANGLADESH.pptx
A CASE STUDY ON CERAMIC INDUSTRY OF BANGLADESH.pptxA CASE STUDY ON CERAMIC INDUSTRY OF BANGLADESH.pptx
A CASE STUDY ON CERAMIC INDUSTRY OF BANGLADESH.pptx
 
HAND TOOLS USED AT ELECTRONICS WORK PRESENTED BY KOUSTAV SARKAR
HAND TOOLS USED AT ELECTRONICS WORK PRESENTED BY KOUSTAV SARKARHAND TOOLS USED AT ELECTRONICS WORK PRESENTED BY KOUSTAV SARKAR
HAND TOOLS USED AT ELECTRONICS WORK PRESENTED BY KOUSTAV SARKAR
 
Engineering Drawing focus on projection of planes
Engineering Drawing focus on projection of planesEngineering Drawing focus on projection of planes
Engineering Drawing focus on projection of planes
 
Tamil Call Girls Bhayandar WhatsApp +91-9930687706, Best Service
Tamil Call Girls Bhayandar WhatsApp +91-9930687706, Best ServiceTamil Call Girls Bhayandar WhatsApp +91-9930687706, Best Service
Tamil Call Girls Bhayandar WhatsApp +91-9930687706, Best Service
 
Block diagram reduction techniques in control systems.ppt
Block diagram reduction techniques in control systems.pptBlock diagram reduction techniques in control systems.ppt
Block diagram reduction techniques in control systems.ppt
 
+97470301568>> buy weed in qatar,buy thc oil qatar,buy weed and vape oil in d...
+97470301568>> buy weed in qatar,buy thc oil qatar,buy weed and vape oil in d...+97470301568>> buy weed in qatar,buy thc oil qatar,buy weed and vape oil in d...
+97470301568>> buy weed in qatar,buy thc oil qatar,buy weed and vape oil in d...
 
Bridge Jacking Design Sample Calculation.pptx
Bridge Jacking Design Sample Calculation.pptxBridge Jacking Design Sample Calculation.pptx
Bridge Jacking Design Sample Calculation.pptx
 
2016EF22_0 solar project report rooftop projects
2016EF22_0 solar project report rooftop projects2016EF22_0 solar project report rooftop projects
2016EF22_0 solar project report rooftop projects
 
FEA Based Level 3 Assessment of Deformed Tanks with Fluid Induced Loads
FEA Based Level 3 Assessment of Deformed Tanks with Fluid Induced LoadsFEA Based Level 3 Assessment of Deformed Tanks with Fluid Induced Loads
FEA Based Level 3 Assessment of Deformed Tanks with Fluid Induced Loads
 
Hazard Identification (HAZID) vs. Hazard and Operability (HAZOP): A Comparati...
Hazard Identification (HAZID) vs. Hazard and Operability (HAZOP): A Comparati...Hazard Identification (HAZID) vs. Hazard and Operability (HAZOP): A Comparati...
Hazard Identification (HAZID) vs. Hazard and Operability (HAZOP): A Comparati...
 
Learn the concepts of Thermodynamics on Magic Marks
Learn the concepts of Thermodynamics on Magic MarksLearn the concepts of Thermodynamics on Magic Marks
Learn the concepts of Thermodynamics on Magic Marks
 
notes on Evolution Of Analytic Scalability.ppt
notes on Evolution Of Analytic Scalability.pptnotes on Evolution Of Analytic Scalability.ppt
notes on Evolution Of Analytic Scalability.ppt
 
Online electricity billing project report..pdf
Online electricity billing project report..pdfOnline electricity billing project report..pdf
Online electricity billing project report..pdf
 
Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...
Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...
Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...
 
Computer Networks Basics of Network Devices
Computer Networks  Basics of Network DevicesComputer Networks  Basics of Network Devices
Computer Networks Basics of Network Devices
 
DC MACHINE-Motoring and generation, Armature circuit equation
DC MACHINE-Motoring and generation, Armature circuit equationDC MACHINE-Motoring and generation, Armature circuit equation
DC MACHINE-Motoring and generation, Armature circuit equation
 
Standard vs Custom Battery Packs - Decoding the Power Play
Standard vs Custom Battery Packs - Decoding the Power PlayStandard vs Custom Battery Packs - Decoding the Power Play
Standard vs Custom Battery Packs - Decoding the Power Play
 
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak HamilCara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
 

Strings in Python

  • 1. G H PATEL COLLEGE OF ENGINEERING & TECHNOLOGY, V. V. NAGAR, ACADEMIC YEAR: 2019-20 (EVEN SEM) CLASS: FINAL YEAR COMPUTER ENGINEERING 2180711-PYTHON PROGRAMMING BY: 160110107031, NARSINGANI AMISHA BATCH: 1B07 Presentation Topic: Strings in Python
  • 2. WHAT ARE STRINGS? • STRINGS ARE ARRAYS OF BYTES REPRESENTING UNICODE CHARACTERS. • PYTHON DOES NOT HAVE A CHARACTER DATA TYPE, A SINGLE CHARACTER IS SIMPLY A STRING WITH A LENGTH OF 1. • SQUARE BRACKETS CAN BE USED TO ACCESS ELEMENTS OF THE STRING. • STRINGS IN PYTHON CAN BE CREATED USING SINGLE QUOTES OR DOUBLE QUOTES OR EVEN TRIPLE QUOTES. • FOR EXAMPLE: STRING1 = ‘WELCOME TO THE GCET WORLD’ STRING2 = “WELCOME EVERYONE!” STRING 3 = '''I'M A GEEK AND I LIVE IN A WORLD OF "GEEKS"'''
  • 3. ITERATING THROUGH STRINGS • USING FOR LOOP WE CAN ITERATE THROUGH A STRING.
  • 4. ACCESSING INDIVIDUAL CHARACTERS • WE CAN ACCESS INDIVIDUAL CHARACTERS OF STRING USING INDEXING. • INDEXING ALLOWS NEGATIVE ADDRESS REFERENCES TO ACCESS CHARACTERS FROM THE BACK OF THE STRING, E.G. -1 REFERS TO THE LAST CHARACTER, -2 REFERS TO THE SECOND LAST CHARACTER AND SO ON. (SEE THE BELOW FIGURE) • WHILE ACCESSING AN INDEX OUT OF THE RANGE WILL CAUSE AN INDEXERROR. P R O G R A M M I N G 0 1 2 3 4 5 6 7 8 9 10 -11 -10 -9 -8 -7 -6 -5 -4 -3 -2 -1
  • 5. ACCESSING INDIVIDUAL CHARACTERS STRING1=“PROGRAMMING” PRINT("INITIAL STRING: ") PRINT(STRING1) PRINT("NFIRST CHARACTER OF STRING IS: ") PRINT(STRING1[0]) #OUTPUT: P PRINT("NLAST CHARACTER OF STRING IS: ") PRINT(STRING1[-1]) #OUTPUT: G
  • 6. STRING SLICING • TO ACCESS A RANGE OF CHARACTERS IN THE STRING, METHOD OF SLICING IS USED. • SLICING IN A STRING IS DONE BY USING A SLICING OPERATOR (COLON). • WE CAN ACCESS SUBSTRINGS USING SLICING • FOR EXAMPLE: C=“PROGRAMMING IS GOOD“ PRINT(C) D=C[5:7] PRINT(D) #OUTPUT: AM E=C[12:14] PRINT(E) #OUTPUT: IS
  • 7. STRING CONCATENATION • JOINING OF TWO OR MORE STRINGS INTO A SINGLE ONE IS CALLED CONCATENATION. • THE + OPERATOR DOES THIS IN PYTHON. • THE * OPERATOR CAN BE USED TO REPEAT THE STRING FOR A GIVEN NUMBER OF TIMES. • FOR EXAMPLE: firstname = “Amisha” lastname = “Narsingani” fullname=firstname + lastname print(fullname) word=“hello “ echo = word*3 print(echo)
  • 8. STRINGS ARE IMMUTABLE • UPDATION OR DELETION OF CHARACTERS FROM A STRING IS NOT ALLOWED. • THIS WILL CAUSE AN ERROR BECAUSE ITEM ASSIGNMENT OR ITEM DELETION FROM A STRING IS NOT SUPPORTED. • ALTHOUGH DELETION OF ENTIRE STRING IS POSSIBLE WITH THE USE OF A BUILT-IN DEL KEYWORD. • THIS IS BECAUSE STRINGS ARE IMMUTABLE, HENCE ELEMENTS OF A STRING CANNOT BE CHANGED ONCE IT HAS BEEN ASSIGNED. ONLY NEW STRINGS CAN BE REASSIGNED TO THE SAME NAME.
  • 9. STRINGS ARE IMMUTABLE Updating a character: STRING1 = "HELLO, I'M A GEEK" PRINT(STRING1) # UPDATING A CHARACTER OF THE STRING STRING1[2] = 'P' PRINT("NUPDATING CHARACTER AT 2ND INDEX: ") PRINT(STRING1) #TYPEERROR: ‘STR’ OBJECT DOES NOT SUPPORT ITEM ASSIGNMENT DEL STRING1[2] PRINT("NDELETING CHARACTER AT 2ND INDEX: ") PRINT(STRING1) #TYPEERROR: ‘STR’ OBJECT DOESN’T SUPPORT ITEM DELETION Updating Entire String: String1 = "Hello, I'm a Geek" print(String1) # Updating a String String1 = "Welcome to the Geek World" print("nUpdated String: ") print(String1) #doesn’t generate an error and gives output successfully del String1 #successfully deletes String1
  • 10. SPLIT METHOD • RETURNALIST OF THE WORDS IN STRING
  • 11. SPLIT SEPARATOR • DEFAULT SEPARATOR IS ANY SPACE(SPACE,NEWLINE,TAB) • TO SPECIFY ANY OTHER SEPARATOR, SPECIFY IT EXPLICITLY.
  • 12. JOIN METHOD • USED TO EFFICIENTLY CONSTRUCT STRINGS FROM MULTIPLE FRAGMENTS. STR.JOIN(ITERABLE) • RETURN A STRING WHICH IS THE CONCATENATION OF THE STRINGS IN ITERABLE. • A TYPEERROR WILL BE RAISED IF THERE ARE ANY NON-STRING VALUES IN ITERABLE. • FOR EXAMPLE: vowels = ['a', 'e', 'i', 'o', 'u’] print(vowels) ['a', 'e', 'i', 'o', 'u’] s = "-".join(vowels) print(s) 'a-e-i-o-u'