Feb-08-2023, 09:50 AM
If the sequence is always the same, then this may do what you need:
def to_upper(text): output = "" list_text = text.split("\nd") for index, words in enumerate(list_text): word = words.lstrip("*") if index == 1: output += word.upper() else: output += word.strip() return output txt = "Here is a \nd Word \nd* in upper case" print(to_upper(txt)) txt = "This is another \nd example \nd*" print(to_upper(txt))
Sig:
>>> import this
The UNIX philosophy: "Do one thing, and do it well."
"The danger of computers becoming like humans is not as great as the danger of humans becoming like computers." :~ Konrad Zuse
"Everything should be made as simple as possible, but not simpler." :~ Albert Einstein
>>> import this
The UNIX philosophy: "Do one thing, and do it well."
"The danger of computers becoming like humans is not as great as the danger of humans becoming like computers." :~ Konrad Zuse
"Everything should be made as simple as possible, but not simpler." :~ Albert Einstein