String HANDLING

======================================================

F-string 

======================================================

filenames = ['document', 'report', 'presentation']


for index,item in enumerate(filenames):

   print(f"{index}-{item}.txt")


======================================================

strip() //trim() in c#

======================================================


lstrip()

rstrip()

rstrip('\n')

strip("R")

------------------------------------------------------

words are 

firstR\n

secondR\n

thirdR\n

file = open('../words.txt')

txt_content = file.readlines()

# print(txt_content[0])


for item in txt_content:

   print(item.rstrip().rstrip('R'))


output:

first

second

third

======================================================

Input Text: The true meaning of obscurity lies underneath the most delicate structures of viscosity. The idea of changing that balance is obscure by itself.

Output Text: The True Meaning Of Obscurity Lies Underneath The Most Delicate Structures Of Viscosity. The Idea Of Changing That Balance Is Obscure By Itself.

======================================================



file = open('../files/essay.txt')

txt_content = file.read()

words = txt_content.split()


for word in words:

   print(word.title(), end = " ")


======================================================

Length of a file

======================================================


file=open('essay.txt','r')

content=file.read()

ch_count=len(content)

print(f"The file contains {ch_count} characters.")