What\'s New in Python 3.9

(kamelia khammar) #1

Now the results will be the same. But the point is you will
save here the condition of if plural ends with suffix. So
let me delete this condition and show you that this is
going to work as well. So if I go ahead and run that out,
the result is quite great. Now, one more point here about
those functions, which are remove suffix and prefix.
Basically, if the suffix that you are trying to remove is
not existing inside the word that you will check, it is
going to return you back the string as it is now. If I
press control B once I mark this function here, basically
I'm going inside what this function includes. And then
you can see that there is documentation that says to us
returns the string with the given suffix being removed if
present. So you can also see here if the string ends with
the suffix swing and that suffix is not empty, it returns
the string itself. So you can see that by this line return
a copy of the original string. So if we want to test that
out, so I'm going to remove the S from book again. I'm
going to add here booked like this. And then if I run our
program again, you can see that it returns the word as it
is and not an exception or something in that case. So this
is a behavior that you want to know as well.

Free download pdf