import re if __name__ == '__main__': input = "Welcome, User_12!!" s = re.sub(r'W+', '', input) print(s) # WelcomeUser_12