How To Extract Numbers From A String In Python?

The easiest way to extract numbers from a Python string s is to use the expression re.findall(‘\d+’, s). For example, re.findall(‘\d+’, ‘hi 100 alice 18 old 42’) yields the list of strings [‘100′, ’18’, ’42’] that you can then convert to numbers using int() or float(). There are some tricks and alternatives, so keep reading … Read more

How to Count the Number of Words in a String in Python

Problem Formulation Given a string – sentence. How many words does the string sentence have within it? Examples: INPUT sentence = “Finxter helps you to master Python.” OUTPUT Number of words: 6 INPUT sentence = “””Lorem ipsum dolor sit amet. Consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.””” OUTPUT … Read more

How I Made a Language Translator using Python

Project Description I recently made a friend online who lives in Paris. I was very excited to learn about her culture and tell her about mine, but the problem here was how would I communicate with her as she was French. That’s when I thought of creating a Python script that would translate a text … Read more

Create Your Own YouTube Video Downloader

Project Description I was watching a certain course on YouTube and wanted to download the entire playlist so that I could watch it while I would travel via flight. However, downloading a YouTube video would mean I would have to use some third-party application to download the videos one by one. That is when I … Read more

Block Websites Using Python in Windows

Recently I came up with an idea to block certain websites because I didn’t want my little brother to surf certain sites while he was using my laptop. Being a smart kid, he knew ways of uninstalling chrome extensions that I used to block websites. That is when I came up with the idea of … Read more