Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

Python: Get number of characters in a String

Using Python built-in function ‘len()’, we can get the number of characters in a string.

 

no_of_chars_in_string.py

str = 'Hello World'
msg = f'"{str}" has {len(str)} characters'

print(msg)

 

Output

"Hello World" has 11 characters

 

 

 

 

Previous                                                 Next                                                 Home


This post first appeared on Java Tutorial : Blog To Learn Java Programming, please read the originial post: here

Share the post

Python: Get number of characters in a String

×

Subscribe to Java Tutorial : Blog To Learn Java Programming

Get updates delivered right to your inbox!

Thank you for your subscription

×