-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path10.1_string_function.py
More file actions
13 lines (12 loc) · 1.4 KB
/
10.1_string_function.py
File metadata and controls
13 lines (12 loc) · 1.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
story="Generating random paragraphs can be an excellent way for writers to get their creative flow going at the beginning of the day. The writer has no idea what topic the random paragraph will be about when it appears. This forces the writer to use creativity to complete one of three common writing challenges. The writer can use the paragraph as the first one of a short story and build upon it. A second option is to use the random paragraph somewhere in a short story they create. The third option is to have the random paragraph be the ending paragraph in a short story. No matter which of these challenges is undertaken, the writer is forced to use creativity to incorporate the paragraph into their writing."
print(story.endswith("personalities"))
print(story.count("on"))
print(story.count("and"))
print(story.capitalize()) #-->this function will capatilize the first word of the string
print(story.find("intellectual")) #-->this will say the index no. of the index
print(story.find("yoyo")) #-->whenever the element is not present in the string then the output will always be -1
# when the occurance of element is more than 1 then it will only show the index of first occurance of that element
print(story.replace("vaishnavi","prettyvaish")) #-->syntax:("old word","new word") #replaces all the words with the new word
greet=" hello "
print(greet)
print(greet.strip()) #--->Removes extra space from the string