Spring Deals - hours only!Up to 70% off on all courses and bundles.-Close
Introduction
Basic utility functions
2. The len() function
Basic manipulation functions
Replacing and splitting
Summary

Instruction

Let's get started. One string function you probably already know is len(). It returns the length of the string—i.e., the number of characters in it.

joke = 'Why does Python live on land? Because it is above C level!'
print(len(joke))

The code above will print 58, which is the length of the joke string.

Exercise

Keep asking the user to provide a username until the input is at least 8 characters long:

Provide a username with a minimum of 8 characters:

When you get a correct username, print:

Thank you!

Stuck? Here's a hint!

Use a while loop to repeat your code as long as len(username) < 8.