[Solved] I have an array of strings. I want to print those that start with the word New.

[ad_1]

input_arr = [
    "New: Hello",
    "How are",
    "you",
    "New: I am",
    "fine"
]

def merge_messages(input_arr):
  delimiter = "New"
  return [delimiter+x for x in " ".join(input_arr).split(delimiter) if x]

print(merge_messages(input_arr))

However, I would highly recommend you take the advice given to you in the comments and read up on Python Strings. You can also view the Python string documentation here

0

[ad_2]

solved I have an array of strings. I want to print those that start with the word New.