.len()
Published Jul 5, 2024
Contribute to Docs
The .len()
method returns the total number of characters present in a specified string.
Syntax
string.len(s)
s
: The input string whose length is to be determined.
Note: Calling
string.len()
without any arguments will result in an error.
Example
The following example demonstrates the usage of the .len()
method:
town = "Llanfairpwllgwyngyllgogerychwyrndrobwllllantysiliogogogoch"lenExample = string.len(town)print(lenExample)
The above code produces the following output:
58
Contribute to Docs
- Learn more about how to get involved.
- Edit this page on GitHub to fix an error or make an improvement.
- Submit feedback to let us know how we can improve Docs.
Learn Lua on Codecademy
- Career path
Computer Science
Looking for an introduction to the theory behind programming? Master Python while learning data structures, algorithms, and more!Includes 6 CoursesWith Professional CertificationBeginner Friendly75 hours - Free course
Learn Lua
Learn the basics of Lua, a general-purpose programming language used for building games, web apps, and developer tools.Beginner Friendly4 hours