G
2 weeks ago
Godfreycountry asked

How can you tell when there are extra spaces in your string?

Palistha Singh
Expert
2 weeks ago

That's a good question!

When you look at the output, it can be difficult to notice extra spaces. That's why it's better to check the code carefully.

For example:

print("godfrey sami")

Here, there are no extra spaces before or after the text.

But:

print(" godfrey sami ")

In this case, there are spaces before and after the text — and you can clearly see that by looking at the code.

There are other ways to check for spaces automatically, but for now, we don't want to overwhelm you.

Just click on Next Lesson to keep going!

Python
This question was asked as part of the Learn Python Basics course.