Re: [Tutor] Iteration issues

2018-06-07 Thread Mats Wichmann
On 06/07/2018 04:21 PM, Roger Lea Scherer wrote: > 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 StackOverf

Re: [Tutor] Iteration issues

2018-06-07 Thread Alan Gauld via Tutor
On 07/06/18 23:21, Roger Lea Scherer wrote: > 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: I think this is wrong. gettysburg is a

Re: [Tutor] Iteration issues

2018-06-07 Thread Roger Lea Scherer
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 pr

Re: [Tutor] Iteration issues

2018-05-12 Thread Peter Otten
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("", "", pu

Re: [Tutor] Iteration issues

2018-05-11 Thread Albert-Jan Roskam
Op 11 mei 2018 21:43 schreef Neil Cerutti : On 2018-05-10, Albert-Jan Roskam wrote: > If a punctuation symbol is in your string: Replace that symbol > with an empty string. > >=>>> maybe something like > > import re > no_interpunction = re.sub("[%s]" % re.escape(string.punctuation), '', > sen

Re: [Tutor] Iteration issues

2018-05-11 Thread Neil Cerutti
On 2018-05-10, Albert-Jan Roskam wrote: > If a punctuation symbol is in your string: Replace that symbol > with an empty string. > >=>>> maybe something like > > import re > no_interpunction = re.sub("[%s]" % re.escape(string.punctuation), '', > sentence) str.translate can be used instead of re

Re: [Tutor] Iteration issues

2018-05-10 Thread Albert-Jan Roskam
Verzonden vanaf mijn Samsung Galaxy-smartphone. Oorspronkelijk bericht Van: boB Stepp Datum: 10-05-18 21:53 (GMT+08:00) Aan: tutor Onderwerp: Re: [Tutor] Iteration issues On Wed, May 9, 2018 at 6:27 PM, Roger Lea Scherer wrote: > Hello, again. > > I want to co

Re: [Tutor] Iteration issues

2018-05-10 Thread Mats Wichmann
On 05/09/2018 05:27 PM, Roger Lea Scherer wrote: > Hello, again. > > I want to count words in a text file. If a word repeats I want to increase > the count by 1; if the word is new to the dictionary, I want to add the > word to the dictionary. Everything works like I would like and expect, > excep

Re: [Tutor] Iteration issues

2018-05-10 Thread boB Stepp
On Wed, May 9, 2018 at 6:27 PM, Roger Lea Scherer wrote: > Hello, again. > > I want to count words in a text file. If a word repeats I want to increase > the count by 1; if the word is new to the dictionary, I want to add the > word to the dictionary. Everything works like I would like and expect,

Re: [Tutor] Iteration issues

2018-05-10 Thread Mats Wichmann
On 05/09/2018 05:27 PM, Roger Lea Scherer wrote: > Hello, again. > > I want to count words in a text file. If a word repeats I want to increase > the count by 1; if the word is new to the dictionary, I want to add the > word to the dictionary. Everything works like I would like and expect, > excep

Re: [Tutor] Iteration issues

2018-05-10 Thread boB Stepp
Greetings! On Wed, May 9, 2018 at 6:27 PM, Roger Lea Scherer wrote: > Hello, again. > > I want to count words in a text file. If a word repeats I want to increase > the count by 1; if the word is new to the dictionary, I want to add the > word to the dictionary. Everything works like I would like

[Tutor] Iteration issues

2018-05-10 Thread Roger Lea Scherer
Hello, again. I want to count words in a text file. If a word repeats I want to increase the count by 1; if the word is new to the dictionary, I want to add the word to the dictionary. Everything works like I would like and expect, except for it only adds the last word of each line to the dictiona