Skip to main content

Posts

Showing posts with the label .isspace()

Python - String Functions - Changing Case, Location, Counting, Formatting, Checking, Regular Expressions

🐍 Some of the String Functions include the following: .capitalize()  .upper()  .lower()  .title()  .count()  .find()  .center()  .expandtabs()  .isalnum()  .isalpha()  .islower()  .isspace()  .istitle()  .isupper()  .endswith() .split() .partition()  Let's take an example string and apply all methods on it. s = 'hello 1st World, 2nd World, and 3rd World.' Changing case Capitalize s.capitalize() Output: 'Hello 1st world, 2nd world, and 3rd world' It capitalizes the first letter of the string   for that output alone . Uppercase s.upper() Output: 'HELLO 1ST WORLD, 2ND WORLD, AND 3RD WORLD' It converts entire string into upper-case for that output alone. Lowercase s.lower() Output: 'hello 1st world, 2nd world, and 3rd world' It converts entire string into lower-case   for that output alone . Location and Counting Count s.count('o') Output: 4 It counts number of occurrences of the string passed in the strin...