The document contains a Python script that processes a string by removing special characters, reversing it, and checking for the presence of specific substrings from a list. It also counts occurrences of words and filters out those that appear less than three times. Additionally, it prints various outputs including the modified string and the results of the substring checks.
Download as TXT, PDF, TXT or read online on Scribd
0 ratings0% found this document useful (0 votes)
2 views
Python 3 - Functions and OOPs 1 String Methods
The document contains a Python script that processes a string by removing special characters, reversing it, and checking for the presence of specific substrings from a list. It also counts occurrences of words and filters out those that appear less than three times. Additionally, it prints various outputs including the modified string and the results of the substring checks.
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1
word1=para
for schar in special1:
word1=word1.replace(schar,"") rword2=word1[69::-1] print(rword2) s=rword2.replace(" ","") l=(len(s)) ns="" for c in s[0:l-1]: ns=ns+c+special2 ns=ns+s[l-1] print(ns) l_len=len(list1) true=0; for li in list1: if(para.find(li)!=-1): true=true+1 if(true==l_len): print("Every string in {} were present".format(list1)) else: print("Every string in {} were not present".format(list1)) w_list=list(word1.split()) print(w_list[0:20]) less_list=list() for less in w_list: if(w_list.count(less)<3): less_list.append(less) less_list1=list(dict.fromkeys(less_list)) print(less_list1[-20:]) print(word1.rfind(strfind))