Regular expressions · 6 / 15 Exercise Easy

First number

Objective

Create a Python program that finds the first number that appears in a text using a regular expression.

Instructions

  • Import the re module.
  • Read a line of text.
  • Search for the first group of digits with re.search(r"\d+", text).
  • If you find it, show the number (.group()). If there are no digits, show No numbers.
Input
Tengo 3 gatos y 12 peces
Output
3

Open the editor in full screen: the statement on the left and your code, the output and the tests on the right.

Start exercise