I am having difficulty creating a function that removes letters of “T” in two different ways. The parameter is a Boolean, if the parameter is True then it will print out a userinput (that is written in my code below) and it will keep asking that same input until the person types in “quit” and when the user does type in “quit” then it will take off all lower case “t” inside the string. If the Boolean is False, then the same process applies but instead of it taking out a lower case “t” it will take off a capital “T”. Also, I want to keep the same type of format I written in my code below, thanks. Btw I am using python 2.4.
def removeT(Boolea): userInput=str(input("Enter a word/sentence you want to process: ")) while userInput: string = (raw_input("Enter a word/sentence you want to process:")) if Boolea == False: userInput = userInput + string while "T" in userInput: index = userInput.find("T") userInput = userInput[:index] + userInput[index+1:] if string == "quit": keepAsking = False return userInput else: userInput = userInput + string while "t" in userInput: index = userInput.find("t") userInput = userInput[:index] + userInput[index+1:] while "T" in userInput: index = userInput.find("T") userInput = userInput[:index] + userInput[index+1:]
1 Answer