## This is the $$sentence$$ you need to evaluate. ## marker: "$$" ## int: 2 def produce(sentence, marker, num): sentence_arr = [] for i in range (len(sentence)): sentence_arr.append(sentence[i]) start_marker = marker[0] end_marker = marker[-1] new_sentence = "" for i in range(len(sentence_arr)): if sentence_arr[i] == start_marker or sentence_arr[i] == end_marker: continue else: ctr = num if sentence_arr[i-1] == end_marker: while ctr != 0 and sentence_arr[i+num] != start_marker: new_sentence = new_sentence + sentence_arr[i] ctr -= 1 else: new_sentence = new_sentence + "*" else: new_sentence = new_sentence + sentence_arr[i] print(new_sentence) produce("This is the $#sentence$# you need to evaluate.", "$#", 2)
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter