The len() Function

The Len Function

This function is extremely useful and often comes up in coursework tasks.

It is used to work out how many characters have been used in a string or another type of object.

Look and run the code below to see a simple example.



Try this for yourself by editing the script below. Create a variable that contains a string and work out the length of the string

The len function can also be used in loops when iterating.


Another example

For example if you wanted to print out how many character there were in a string and which character it was…

Similar Posts

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.