Skip to content

Instantly share code, notes, and snippets.

@VladSem
Last active October 1, 2015 05:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save VladSem/04e60084f3efd7ee661b to your computer and use it in GitHub Desktop.
Save VladSem/04e60084f3efd7ee661b to your computer and use it in GitHub Desktop.
(Python) How to remove all whitespace from string and how to capitalize the first letter of each word in a string?
#!/usr/bin/python
# -*- coding: utf-8 -*-
string_name = "hi Vlad, welcome to the California"
def mv_uppercase_rm_whitespaces(string_name):
a = string_name.title() # capitalize the first letter
b = a.replace(',', '') # remove comma
c = b.replace(' ', '') # remove whitespace
print c
mv_uppercase_rm_whitespaces(string_name)
# result
# HiVladWelcomeToTheCalifornia
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment