My question is, in all of the walrus examples, they use the whole object for the boolean, e.g.
if (x := len(s)) > 5:
print(x)
converts
x = len(s)
if x > 5:
print(x)
Is there a way to do it for slices of x, if x were a string? e.g. x[-1] != ','
Here is code I am looking to convert to walrus operator
title = book.find(class_='title').get_text()
if title[-1:] == '\n':
title = title[:-1]