Logic Building
# Take string input
s = input("Enter a string: ")
# Get length
length = len(s)
print(f"Length: {length}")Output
Enter a string: Hello Length: 5
Use len() function to get string length.
Key Concepts:
len(s)returns number of characters- Includes spaces and special characters
- Empty string has length 0