Timeline for python search replace and join with delimiter
Current License: CC BY-SA 4.0
14 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Oct 27, 2019 at 17:22 | answer | added | Nicole Douglas | timeline score: 0 | |
Oct 27, 2019 at 16:58 | vote | accept | spence | ||
Oct 27, 2019 at 16:56 | comment | added | spence |
I think I got it, I added a try statement after for key and before the if statement: try: mod[key] == 'r' and mod[key+4] == 't' except KeyError: break
|
|
Oct 27, 2019 at 16:41 | comment | added | spence |
Aha, I kind of thought that's what you were getting at, lucky guess on my part. I see now. KeyError: 10 . Originally, I had a break statement so it would pop out after it found the word, but then it would miss another instance of 'right' in the phrase if there was one. I'm going to play around with a fix.
|
|
Oct 27, 2019 at 16:39 | comment | added | Carsten S | sorry, I had missed a line in your code. Try “rightcrash”. | |
Oct 27, 2019 at 16:36 | comment | added | spence |
It returned "crash". I was expecting it to fail. Trying to find what you were getting at I did see another error my code would introduce, if a a five letter sub-string begins with r and ends with t that is not the word right, it would modify that too. That's not good. What did you see about the test ("crash",) ?
|
|
Oct 27, 2019 at 9:32 | comment | added | Carsten S | Try your code on test3=(“crash”,). | |
Oct 27, 2019 at 8:18 | history | became hot network question | |||
Oct 27, 2019 at 3:01 | history | tweeted | twitter.com/StackCodeReview/status/1188289532497666049 | ||
Oct 27, 2019 at 1:56 | vote | accept | spence | ||
Oct 27, 2019 at 16:57 | |||||
Oct 27, 2019 at 1:56 | history | edited | spence | CC BY-SA 4.0 |
typos
|
Oct 27, 2019 at 1:17 | answer | added | watch-this | timeline score: 6 | |
Oct 27, 2019 at 0:10 | review | First posts | |||
Oct 27, 2019 at 1:11 | |||||
Oct 27, 2019 at 0:07 | history | asked | spence | CC BY-SA 4.0 |