Answered step by step
Verified Expert Solution
Question
1 Approved Answer
HELP WITH THIS PYTHON PROGRAM PLEASE! Write a Python program that contains two functions: main function and search function The search function has two parameters:
HELP WITH THIS PYTHON PROGRAM PLEASE! Write a Python program that contains two functions: main function and search function The search function has two parameters: my string and target. target is the substring to search for within my,string. The searching is implemented using the string object's find(substring) method. The search function should print the index of the first occurrence of the target substring if it is found: Otherwise (target does not exist in my string), print 'XX is not found' (KX is the target substring. Inside the main function: (1) create a string variable my string and assign 'Commputer#' to it; (2) use the rstrip(char) method to strip off the # on the right end of my, string, update and print my,string: (3) Call the upper) method to capitalize the lowercase letters in my,string, update and print my,string:(4) Call the replace(substring, new, substring) method to replace MM' with M; update and print my string: (5) Use the search function twice to search for 'C" and 'm, respectively After strip: Commputer After capitalization: COMMPUTER After replacement: cOMPUTER The index of C is 0 m is not found
HELP WITH THIS PYTHON PROGRAM PLEASE!
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started