I need to create a function that receives a string and checks if the last char is a “\n” or not. If so, returns the same string without it’s last char.
The ways I can think of doing this are not the slightest efficient. I need it to be efficient.
I need to create a function that receives a string and checks if the
Share
It’s hard to give a precise answer to your question as you do not give any context.
The simplest solution I can think of is: