Editor settings

General settings

Save settings

Learn to program with Python

Get the length of a string #

You can get the length of a string using the len() function. The len() function takes one argument and returns the length of that argument.

For example:

my_string = "Hello, World!"
length = len(my_string)
print(length) # Output: 13

Exercise #

  • Assign the variable length with the length of the variable greeting
  • Use the function len()
Output will be displayed here