Skip to content

Instantly share code, notes, and snippets.

@prettyirrelevant
Created November 24, 2020 14:39
Show Gist options
  • Save prettyirrelevant/13711f4fd9e4968ff4373503e143a1dc to your computer and use it in GitHub Desktop.
Save prettyirrelevant/13711f4fd9e4968ff4373503e143a1dc to your computer and use it in GitHub Desktop.
a python script that calculates the time it'll take to read a given text( i think it's buggy)
def get_time_to_read(text: str):
striped_text = strip_tags(text)
word_cleaned = re.sub(r" /[^\w ]/g", "", striped_text)
word_count = len(word_cleaned.split(" "))
reading_time = math.floor(word_count / 200)
if reading_time <= 1:
return f"{str(reading_time)} min"
else:
return f"{str(reading_time)} mins"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment