The rstrip() removes characters from the right based on the argument (a string specifying the set of characters to be removed).
string.rstrip(chars)
If the char argument is not provided, all leading whitespaces on the right are removed from the string.
The rstrip() returns a copy of the string with trailing characters stripped.All combinations of characters in the chars argument are removed from the right of the string until first mismatch.
random_string = ' this is good'# Leading whitepsace are removedprint(random_string.rstrip())# Argument doesn't contain 'd'# No characters are removed.print(random_string.rstrip('si oo'))print(random_string.rstrip('sid oo'))website = 'www.cppsecrets.com/'print(website.rstrip('m/.'))
**********END OF ARTICLE **********
Comments