⊗pyPmBsSL 26 of 208 menu

String Length in Python

The number of characters in a string (its length) can be found using the len function:

print(len('abc')) # 3

The string can also be stored in a variable:

txt = 'abc' print(len(txt))

Space is also a symbol:

txt = 'ab c' print(len(txt)) # 4

Given a string:

txt = 'abcdef'

Print the length of this string to the console.

Given a string:

txt = 'ab cd ef'

Print the length of this string to the console.

English
AfrikaansAzərbaycanБългарскиবাংলাБеларускаяČeštinaDanskDeutschΕλληνικάEspañolEestiSuomiFrançaisहिन्दीMagyarՀայերենIndonesiaItaliano日本語ქართულიҚазақ한국어КыргызчаLietuviųLatviešuМакедонскиMelayuမြန်မာNederlandsNorskPolskiPortuguêsRomânăРусскийසිංහලSlovenčinaSlovenščinaShqipСрпскиSrpskiSvenskaKiswahiliТоҷикӣไทยTürkmenTürkçeЎзбекOʻzbekTiếng Việt
We use cookies for website operation, analytics, and personalization. Data processing is carried out in accordance with the Privacy Policy.
accept all customize decline