Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

5 points Status: Not Submitted - def remove_all_from_string(word, letter): for i in word: if i == letter: num = word.find(letter) word = word[:num] + word[num+1:]

image text in transcribed

5 points Status: Not Submitted - def remove_all_from_string(word, letter): for i in word: if i == letter: num = word.find(letter) word = word[:num] + word[num+1:] print word print remove_all_from_string("hello", "1") Write a function called remove_all_from_string that takes two strings, and returns a copy of the first string with all instances of the second string removed. You can assume that the second string is only one letter, like "a". Test your function on the strings "hello" and "1". Print the result, which should be: heo You must use: A function definition with parameters. A while loop. The find method. Slicing and the + operator. A return statement

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions

Question

What is environmental design?

Answered: 1 week ago