How do you remove a middle initial from a name in python?
Question: I'm trying to figure out something that seems like it should be simple. I'm
trying to remove the middle initial from names, but I'm not sure how to do it
without making a replace() for every letter of the alphabet. This is what I'm
looking for:

(Starts as)

"John D Smith"

"Robert B Johnson"

(Ends as)

"John Smith"

"Robert Johnson"

What is the simplest way of accomplishing the above in Python? The middle
initial is random, but is always surrounded by white space.


Answer: May this help, based on your post

    
    
    >>> import re
    >>> re.sub(' [A-Z]* ', ' ', "John D Smith")
    'John Smith'
    >>> re.sub(' [A-Z]* ', ' ', "Robert B Johnson")
    'Robert Johnson'
    

