Listing 12-01: Search for number sequences

##############################################################################
# Python From Scratch
# Autor: Nilo Ney Coutinho Menezes
# Editora Novatec (c) 2010-2024
# Site: https://pythonfromscratch.com
#
# File: listing\chapter 12\12.01 - Search for number sequences.py
# Description: Search for number sequences
##############################################################################

entry = "ABC431DEF901c431203FXEW9"
output = []
number = []
for character in entry:
    if "0" <= character <= "9":
        if not number:
            output.append(number)
        number += character
    elif number:
        number = []
for found in output:
    print("".join(found))
Click here to download the file