Remove the newline character in a list read from a file [duplicate]

str.strip() returns a string with leading+trailing whitespace removed, .lstrip and .rstrip for only leading and trailing respectively.

grades.append(lists[i].rstrip('\n').split(','))

Leave a Comment

error code: 521