Free String Explorer: try Python and JavaScript string operations

Free Python exercises for beginners

Build confidence with small Python programs before tackling a larger project. Start with values and calculations, then practice cleaning text, reading errors, and working with strings. These free lessons and exercises are drawn from the existing StringClass courses.

No account needed for free previews · Hints, tests, and explained answers

Before you start: New to programming? Begin with Python Foundations. If you already use variables, functions, loops, lists, and dictionaries, try text automation or debugging. The string interview preview assumes those same basics.

Worked example: remove blank labels and surrounding whitespace

Suppose a small contact list contains blank labels and extra spaces. Keep meaningful text in its original order. Removing whitespace is different from removing duplicates: both occurrences of Ada should remain.

labels = ["  Ada  ", "", "Grace ", " Ada "]
cleaned = []
for label in labels:
    text = label.strip()
    if text:
        cleaned.append(text)
print(cleaned)
# ['Ada', 'Grace', 'Ada']

strip() returns a new string with surrounding whitespace removed. An empty string is false in an if condition, so blank labels are skipped. The loop appends to a new list and leaves the input list unchanged. Try an empty list, a label containing only spaces, and a repeated name before moving on.

How to practice with the examples and tests

For each exercise, write down the function’s input and required return value. Predict the empty-input result, implement the smallest version, then run the supplied tests. A printed message is not a substitute for a returned result. Use hints in order and compare the reference solution only after trying your own approach.

Choose your next free lesson or exercise

Start from the basics

Work with returned values, text, addition, remaining quantities, and repeated amounts. The first two lessons explain the supplied function wrapper, so you can start without knowing how to design functions.

Read a free lesson

Try free exercises with hints and solutions

See the full Python Foundations course outline →

Practice text and data automation

Count records, keep meaningful lines, normalize labels, clean selected fields, and split key-value text. Read each contract carefully: missing data and blank text do not always mean the same thing.

Read a free lesson

Try free exercises with hints and solutions

See the full Practical Python: Text and Data Automation course outline →

Learn by repairing a bug

Practice empty inputs, missing fields, division by zero, and small reproductions. Explain why the starter fails before changing it, then check a boundary case.

Read a free lesson

Try free exercises with hints and solutions

See the full Debugging and Testing Code — Python course outline →

Questions about free Python practice

Do I need to install Python?

The linked browser exercises run in an isolated Python workspace on your device. No Python installation or account is needed for these free previews. The runtime may take a moment to load the first time.

Can I see hints and answers?

Each linked free exercise includes progressive hints, a reference solution, an explanation, and tests. Read the stated contract and attempt your own solution before revealing the answer.

What should I study next?

Continue the course whose free examples match your goal: Foundations for basics, Practical Python for small automation tasks, Debugging for repair skills, or String Interviews for string-focused practice. Course access and practice access are separate purchase options; the Complete Bundle includes both.

Keep your progress when you are ready

Free previews are available without an account. An account lets you save your exercise code and progress. Create an account to save progress. Paid lessons and practice are clearly separated from these free links. Compare Course access, Practice Pack, and Complete Bundle.

Free lessons and coding exercises

Find a starting point, read a worked example, and try matching exercises with hints and solutions. No account is needed for free previews.

Read practical Python, JavaScript, and SQL tutorials →