I'm learning python and was wondering if it's possible to write the below code differently, but have the same function. The purpose of this code is to split \n
and remove spaces from the right:
contents = readlines()
stripped_contents = [(element.rstrip()) for element in contents]