text = "This is string, remove text after second comma, to be removed." print(",".join(text.split(",")[:2])) # result: This is string, remove text after second comma