- 
                Notifications
    
You must be signed in to change notification settings  - Fork 266
 
T I Double Guh ER
        LeWiz24 edited this page Aug 27, 2024 
        ·
        5 revisions
      
    TIP102 Unit 1 Session 1 Standard (Click for link to problem statements)
- 💡 Difficulty: Easy
 - ⏰ Time to complete: 5 mins
 - 🛠️ Topics: Strings, Loops
 
Understand what the interviewer is asking for by using test cases and questions about the problem.
- 
Q: Should the function be case-sensitive when removing letters?
- A: No, the function should remove both uppercase and lowercase occurrences of the letters 
t,i,g,e, andr. 
 - A: No, the function should remove both uppercase and lowercase occurrences of the letters 
 - 
Q: What if the input string does not contain any of the letters
t,i,g,e, orr?- A: The function should return the original string unchanged.
 
 - 
The function
tiggerfy()should take a string s and return a new string with the letters t, i, g, e, and r removed. 
HAPPY CASE
Input: "suspicerous"
Expected Output: "suspcous"
EDGE CASE
Input: "Trigger"
Expected Output: "
Input: "Hunny"
Expected Output: "Hunny"
Plan the solution with appropriate visualizations and pseudocode.
General Idea: Define a function that iterates through the string and builds a new string excluding the specified characters.
1. Define the function `tiggerfy(s)`.
2. Define the characters to remove as a string `remove_chars = "tiger"`.
3. Initialize an empty string `result` to store the modified string.
4. Iterate through each character in the input string `s`.
5. For each character, check if it (in lowercase) is not in `remove_chars`.
6. If it is not, add the character to `result`.
7. Return the `result` string.- Not handling the case sensitivity of the characters.
 - Not correctly iterating through all characters of the input string.
 
Implement the code to solve the algorithm.
def tiggerfy(s):
    # Define the characters to remove
    remove_chars = "tiger"
    
    # Initialize an empty string to store the result
    result = "
    
    # Iterate through each character in the input string
    for char in s:
        # If the character (in lowercase) is not in remove_chars, add it to the result
        if char.lower() not in remove_chars:
            result += char
    
    # Return the new string
    return result