Python for Engineers

Solve Problems by Coding Solutions - A Complete solution for python programming

Blog Pages

▼

Reversal of a string

›
startmsg = "hello" endmsg = "" for i in range(0,len(startmsg)):   endmsg = startmsg[i] + endmsg print (endmsg)

String replacing with another string with occurrence count

›
s='brown box red pencil brown pen red pen red box' print (s) s1=s.replace('red','brown') print (s1) s='brow...

Searching the pattern in a String using find and index

›
try:     s="brown box red pencil brown pen red pen red box"     print s.find("red")     print s.find("red",...

String operations to remove white spaces

›
s=" t  ioi ii " t1=s.rstrip() # removes trailing white space t2=s.lstrip() # removes leading white space t3=s.strip()  # remove...

File operation for copying content of one file to another without for loop

›
#  Implementation without for loop #  Copying content of 1.txt file to 2.txt after creation of file #  Please provide the 1.txt file in th...
‹
›
Home
View web version
Powered by Blogger.