Q:

Python List Formatting and Updation

I have a list Eg. a = ["dgbbgfbjhffbjjddvj/n//n//n' "]
How do I remove the trailing new lines i.e. all /n with extra single inverted comma at the end? 
Expected result = ["dfgjhgjjhgfjjfgg"] (I typed it randomly) 

A:

you can use string rstrip() method.
usage:
str.rstrip([c])

where c are what chars have to be trimmed, whitespace is the default when no arg provided.
example:
a = ['Return a copy of the string\n', 'with trailing characters removed\n\n']                                 
[i.rstrip('\n') for i in a]

result:
['Return a copy of the string', 'with trailing characters removed']

more about strip():
https://www.tutorialspoint.com/python3/string_rstrip.htm

