Last active
October 1, 2015 05:41
-
-
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?
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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