Member-only story

Interview question: Remove special characters from a lower case string

Crystal X
2 min readJun 20, 2023

--

It is important to know how to perform basic programming if one wants to become a Python developer.

One interview question that may crop up is how to remove special characters from a lower case string.

I have developed two ways that this question can be answered and will discuss them in this blog post.

The first method to remove special characters from a lower case string can be seen in the psuedocode below:-

  1. Define the variable, string, which is composed of alphabetical characters and special characters.
  2. Use Python’s lower function to convert the string to lower case.
  3. Define the variable, alpha_chars, which is all of the characters that can be included in the string.
  4. Define the variable, new_string, which is an empty string.
  5. Create a for loop where the variable, i, iterates through the elements of the variable, string. If i is in alpha_chars then add the value of i to the variable, new_string.

The code in python for this algorithm can be seen below:-

The second way to remove special characters from a lower case string is to use Python’s inbuilt re module. The re module is an acronym for regular…

--

--

Crystal X
Crystal X

Written by Crystal X

I have over five decades experience in the world of work, being in fast food, the military, business, non-profits, and the healthcare sector.

No responses yet