Would like to be able to replace every nth word in a text file with a blank space. I'm sure python is so capable.
eldeingles 0 Newbie Poster
Recommended Answers
Jump to Postlol
How about some search?
I've written something easilly adjustable for some user something like one week ago.
Jump to Postthat's simple
txt = "hello world hello world hello world hello world" def replace_nth_word(n, text): text = text.split() j = 0 for i in range(len(text)): j += 1 if j == n: j = 0 text[i] = " " return " ".join(text) print replace_nth_word(3, txt) """ output: …
Jump to PostWould like to be able to replace every nth word in a text file with a blank space. I'm sure python is so capable.
If this is homework, please show at least a little effort!
All 9 Replies
Beat_Slayer 17 Posting Pro in Training
ultimatebuster 14 Posting Whiz in Training
vegaseat 1,735 DaniWeb's Hypocrite Team Colleague
eldeingles 0 Newbie Poster
TrustyTony 888 ex-Moderator Team Colleague Featured Poster
eldeingles 0 Newbie Poster
TrustyTony 888 ex-Moderator Team Colleague Featured Poster
eldeingles 0 Newbie Poster
TrustyTony 888 ex-Moderator Team Colleague Featured Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.