How do I remove a trailing newline from a string in Python The Problem Using Python, how can I remove one or more newline characters at the end of a string, if present?