Count Characters

Count the number of characters in a string, with option to exclude spaces.

Code

General
len(str) if includeSpaces else len(str.replace(' ', ''))

Parameters

The string to count characters in

Whether to include spaces in the count

Server

More Python Snippets