realpython/python-basics-exercises

Possible Issue?

datalenk opened this issue · 3 comments

Hello, I'm going through the Python Basic book and going through the excersises and I've come across a possible code error in the PDF page 85, question 5. The solutions to exercises shows the solution, but when entered it doesn't show as True as the instructions says. I've already tried the solution on both Python 2 and Python 3 and no luck. Can someone, please advise?

Github: ch04-strings-and-string-methods/3-manipulate-strings-with-methods.py
Python Basic book PDF: Pg: 85, Question 5

sc1

sc2

sc3

@datalenk you'll have to use .strip() and .lower()

Use lower for tge 1st and tge 3rd one.
And use lower and strip for the 4th one.
Which will give you the true answer for all the strings.

string1="Becoomes"
string2="becomes"
string3="BEAR"
string4=" bEautiful"
print(string1.lower().startswith("be"))
print(string2.startswith("be"))
print(string3.lower().startswith("be"))
print(string4.lower().strip().startswith("be"))