I've done my research on stack overflow and could not find an answer that works out for me even though similar questions have been posted in the past. My issue is that I want to add string values that I am getting from a for loop that goes through a list and matches to a regular expression. I want to add them to a combined list of values, I am using a clean function that works on the submission of a form but when the data prints into my terminal it comes out like this:
['#example']
['#test']
when I want those values to print like this:
['#example', '#test',]
Here's my code in my views.py
def clean(self):
data = self.cleaned_data
regex = re.compile("\B#\w\w+")
tweeters = data['tweets']
split_tweets = tweeters.split()
for x in split_tweets:
if re.search(regex, x):
master_list = [x]
print master_list