I created three text files that each have 10 random numbers separated by commas. I then have a python program that accepts the name of a text file from the user, reads the numbers from the text file into a list, and then sorts and prints the original list and the sorted list.
prompt = raw_input("Enter the name of the text file you want to open: ")
fileopen = open(prompt)
for line in fileopen:
numbers = line.split(",")
sortednumbers = sorted(numbers)
print numbers
print sortednumbers
However, the resulting lists that are printed always contain exactly one value that has a "\n" attached to the end of the number (e.g. 99\n). I've noticed it's always the last number in the text file. How can I get it to just display the numbers from the text files without the "\n"?