What is the equivalent function of chomp() or chop() at python to remove the newline from the end of any string?
Here is a small piece of code. This will just remove the newline from the hello world string using strip() function.
string = "hello world\n"
string = string.strip() ## chomping or choping the new line
To chomp, you can use regular expression too. Using \s you can do it easily. It will be something like that. Means replacing space with space. But at the end it will eat that new line.
string = re.sub('\s', ' ', string)