I've given up again. I've tried the python documentation, I've tried to implement the above suggestions, I've tried the translate thing with a table that I did not include this time because I couldn't get it to work, I've looked at StackOverflow, Quora and another website, so many things seem so promising, but I just can't get them to work nor figure out why they won't. I've started from scratch again.
********** import string gettysburg = open("C:/Users/Roger/Documents/GitHub/LaunchCode/gettysburg.txt", "r") puncless = "" for char in gettysburg: if char in string.punctuation: gettysburg.replace(char, "") else: puncless += char print(puncless) ********** The "puncless" part works fine, except it does not replace the punctuation like I expect and want. Thank you for all your help already, but I need some more if you have any. :) Thanks. On Sat, May 12, 2018 at 12:40 AM, Peter Otten <__pete...@web.de> wrote: > Neil Cerutti wrote: > > > punctuation_removal_table = str.maketrans({c: None for c in > > string.punctuation}) > > Alternative spellings: > > >>> from string import punctuation > >>> (str.maketrans({c: None for c in punctuation}) > ... == str.maketrans(dict.fromkeys(punctuation)) > ... == str.maketrans("", "", punctuation)) > True > > > _______________________________________________ > Tutor maillist - Tutor@python.org > To unsubscribe or change subscription options: > https://mail.python.org/mailman/listinfo/tutor > -- Roger Lea Scherer 623.255.7719 _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor