Answer the question
In order to leave comments, you need to log in
How to change a line and dot it?
There is a line that contains something like this `var = 'When parents goWhat do they listen toWhy How' `
As an output, I need to get `When parents go. What do they listen to. Why How` . But my code below puts a period before the word 'How' `When parents go. What do they listen to. why. How`
_
var = 'When parents goWhat do they listen toWhy How'
words = ['When', 'Why', 'What', 'How']
for word in words:
if not var.startswith(word):
var = var.replace(word, f'. {word}')
print(var)
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question