I am now even more confused. Now I'm getting new errors.
When I append the items how do I get rid of the blank spaces that show ''?
Error:Traceback (most recent call last):
File "C:\Users\Irhcsa\Desktop\test.py", line 26, in <module>
main()
File "C:\Users\Irhcsa\Desktop\test.py", line 19, in main
if newList[0][0] != newList[0][1]:
IndexError: string index out of range
When I try to run your code. I think I might be mentally retarded or something.When I append the items how do I get rid of the blank spaces that show ''?
def main(): newList = [] inFile = open("names.txt", 'r') inRead = inFile.readlines() inRead.sort() for name in inRead: name = name.rstrip('\n') newList.append(name) print(newList) inFile.close() main()