Remove Tabs in a String
In this lesson, we will learn how to remove tabs from a string using recursion.
We'll cover the following...
What does “Removing Tabs from a String” mean?
Our task is to remove all tabs from a string. This includes the character \t
and " "
from a string.
Removing spaces from a string
Implementation
Press + to interact
def remove(string):# Base Caseif not string:return ""# Recursive Caseif string[0] == "\t" or string[0] == " ":return remove(string[1:])else:return string[0] + remove(string[1:])# Driver Codeprint(remove("Hello\tWorld"))
...