<jupyter_start><jupyter_text>Creating a String<jupyter_code>myString = "Hello"

print(myString)

myString = "Hello"
print(myString)


myString = '''Hello'''
print(myString)<jupyter_output>Hello
Hello
Hello<jupyter_text>Accessing Characters in String<jupyter_code>myString = "Hello"

# print first char
print(myString[0])

# print last char
print(myString[-1])

# slicing 2nd to 5th char
print(myString[2:5])
print(myString[15])
print(myString[1.5])<jupyter_output><empty_output><jupyter_text>Changing / Deleting Strings<jupyter_code>myString = "Hello"
myString[4] = 's'  # strings are immutable
del myString  # delete complete string
print(myString)<jupyter_output><empty_output><jupyter_text>String Operations  Concatenation<jupyter_code>s1 = "Hello "
s2 = "Pramit"

# concatenation
print(s1 + s2)

# repeat string n times
print(s1*3)<jupyter_output>Hello Pramit
Hello Hello Hello<jupyter_text>Iterating through string<jupyter_code>count = 0
for l in "Hello Word":
    if l == 'o':
        count += 1
print(count, ' letters found')<jupyter_output>2  letters found<jupyter_text>String Membership Test<jupyter_code>print('l' in "Hello World")
print('or' in "Hello World")<jupyter_output>True<jupyter_text>String Methods<jupyter_code>'Hello'.lower()
"Hello".upper()
"This will split all words in a list".split()
' '.join(['This', 'will', 'split', 'all', 'words', 'in', 'a', 'list'])
"Good Morning".find("Mo")
s1 = "Bad Morning"

s2 = s1.replace("Bad","Good")

print(s1)
print(s2)<jupyter_output>Bad Morning
Good Morning<jupyter_text>Python Program to Check where a String is Palindrome or not ?<jupyter_code>myStr = "Abba"

# convert entire string in upper or lower
myStr = myStr.lower()

# reverse
revStr = reversed(myStr)

# check if both are equal or not
if list(myStr) == list(revStr):
    print("Given String is Palindrome")
else:
    print("Given String is not Palindrome")<jupyter_output>Given String is Palindrome<jupyter_text>Python Program to Sort Words in Alphabetic Order?<jupyter_code>myStr = "python Program to Sort words in Alphabetic Order"

# break into list
words = myStr.split()

# sort 
words.sort()

# print the sorted words
for word in words:
    print(word)<jupyter_output>Alphabetic
Order
Program
Sort
in
python
to
words
{'fraction_non_alphanumeric': 0.1239964317573595, 'fraction_numerical': 0.011150758251561105, 'mean_word_length': 6.451827242524917, 'pattern_counts': {'":': 1, '<': 30, '<?xml version=': 0, '>': 30, 'https://': 0, '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': '9', 'dir': 'jupyter-structured-clean-dedup', 'id': '573875', 'license': 'MIT', 'n_tokens_mistral': 843, 'n_tokens_neox': 818, 'n_words': 206, 'path': 'Machine Learning and Artificial Intelligence/01. Fundamentals-of-Programming/02.Python-for-Data-Science_Data Structures/06.Strings.ipynb', 'repo_name': 'pramit026/Machine-Learning-and-Artificial-Intelligence', 'size': '2242'}