Menu

(Solved) : Write Python Code Exercise Py File Make Sure Print Statement State Exercise Number Print O Q44028805 . . .

Write Python code for each exercise in the same .py file, makesure to print a statement to state the exercise number before youprint each output and include comments to easily read yourcode.

Exercise 1 – Strings

Write a program that prompts the user to enter two inputs: sometext and a word. The program outputs the starting indices of alloccurrences of the word in the text. If the word is not found, theprogram should output “not found”.

Example1:

Input1: my dog and myself are going to my friend

Input2: my

Output: 0 11 31

Example 2:

Input1: Programming is fun

Input 2: my

Output: not found

Exercise 2 – Lists

Write a function sum67 that takes a list as an input parameterand returns the sum of the numbers in the list, except ignoresections of numbers starting with a 6 and extending to the next 7(every 6 will be followed by at least one 7). Return 0 for nonumbers.

Examples:

sum67([1, 2, 2]) → 5

sum67([1, 2, 2, 6, 99, 99, 7]) → 5

sum67([1, 1, 6, 7, 2]) → 4

sum67([1, 6, 2, 2, 7, 1, 6, 99, 99, 7]) → 2

sum67([1, 6, 2, 6, 2, 7, 1, 6, 99, 99, 7]) → 2

Expert Answer


Answer to Write Python code for each exercise in the same .py file, make sure to print a statement to state the exercise number be…

OR