Python Strings
Anything between the single or double quotes in python code is considered as ‘strings’ or ‘str’.
A string is just a collection of characters (numbers, alphabets, special char etc) within single or
double quotes.
String1 = 'Hello, Great Learning'
String2 = "Hello, Great Learning"
There is a keyword ‘str’
str
To convert any data point to string , use str(data_point)
number= 1234
str(number) # will give output as ‘1234’
The below code will give error as single quoted 1 will not be identified as a numeric value
[email protected]
9T6KVYUXDH'1'+1
This will concatenate the two strings
'1'+'1' # will give '11'
Please refer to official Python Documentation:
o https://docs.python.org/3/library/string.html
o https://docs.python.org/3/library/stdtypes.html#string-methods
Proprietary content. ©Great Learning. All Rights Reserved. Unauthorized use or distribution prohibited.
This file is meant for personal use by [email protected] only.
Sharing or publishing the contents in part or full is liable for legal action.