Page 154 - CodePilot V5.0 C8
P. 154
You can use the strip() method to clean extra spaces from user input before processing it.
Program 13 A program to demonstrate the use of built-in string functions.
Program13.py
File Edit Format Run Options Window Help
str= "Welcome to Python Programming"
print(str.count("o"))
print(len(str))
print(str.lower())
print(str.replace("Python","Java"))
print(str.title())
print(str.upper())
print(str.capitalize())
The output of the preceding code is as follows:
Output
4
29
welcome to python programming
Welcome to Java Programming
Welcome To Python Programming
WELCOME TO PYTHON PROGRAMMING
Welcome to python programming
RAPID RECALL Tick ( ) if you know this.
1. In slicing, specify a range of indexes to extract the characters from the string.
2. The lower() converts a string into lower case.
Ask
AGENT
OrangeAI
Create a menu-driven program to implement different string functions.
Study
152
CodePilot (V5.0)-VIII

