I have txt file with names which look like that:
Hans
Anna
Vladimir
Michael
Ed
Susan
Janice
Jo
I want to print the sum of all the names length:
with open(r"C:\people_names.txt", "r") as name_file:
sum_names = (len(x) for x in name_file)
print(sum(sum_names))
The problem is that there is "\n" after every name which count as a letter and the last name dont have "\n",
Thats why I cant do len(x)-1
Will be glad for any suggestions how to do the sum :)