Print list to txt file without [brackets] in PYTHON
问题 I am trying to take a list of names, alphabetize them and print them to a new list. Here is my code: names = [] newnames = [] with open("C:/names.txt", "r") as infile: for row in infile.readlines(): name = row.split() names.append(name) for x in sorted(names): newnames.append(x) print newnames f = open("C:/newnames.txt", "w") f.write("\n".join(str(x) for x in newnames)) f.close() my problem is that it prints fine except for the brackets: ['Bradley'] ['Harold'] ['Jackson'] ['Lincoln'] [