Logo

Programming-Idioms

History of Idiom 169 > diff from v22 to v23

Edit summary for version 23 by LucianoRamalho:
New Python implementation by user [LucianoRamalho]

Version 22

2018-02-05, 11:19:55

Version 23

2018-02-14, 15:11:54

Idiom #169 String length

Assign to integer n the number of characters of string s.

This can be different from the number of bytes of s.

Idiom #169 String length

Assign to integer n the number of characters of string s.

This can be different from the number of bytes of s.

Extra Keywords
size
Extra Keywords
size
Code
n = len(s)
Comments bubble
If s is a Python 3 str, or a Python 2 unicode, len(s) returns the number of characters. If s is a Python 2 str or a Python 3 bytes, len(s) returns the number of bytes.