Hey!
First time posting a question here, I usually find the answer by searching but this time I came up dry.
I'm writing a really simple function in Python but it's refusing to return a value. Basically you're supposed to input HTML-code and it will remove all the HTML tags (by searching for < and >, then stitching together a new string).
def pretty_print(source_code):
article_nohtml = remove_html(source_code)
print(article_nohtml)
def remove_html(article):
code_starts_at = article.find('<')
if code_starts_at != -1:
beginning_of_article = article[:code_starts_at]
code_ends_at = article.find('>')+1
end_of_article = article[code_ends_at:]
stitched_article = beginning_of_article + end_of_article
remove_html(stitched_article)
else:
print(type(article))
print(article)
return article
#Test the function
remove_html('<p>This is a text to <strong> try the script out </strong></p>\n<p>Is this working for you?</p>')
This piece of code does not contain anything extraordinary so it is a mystery to me why it isn't working. I've added the last two print calls just to test the function and they return class 'str' and the full string which is looking fine but when the pretty_print function is supposed to print the article it only outputs None.
Thankful for any help I can get, this should be straight forward but I'm probably missing something.