Skip to content Skip to sidebar Skip to footer

Check If String Is Of Nine Digits Then Exit Function In Python

I have a function in python that returns different output of strings (Text). And I have different parts that I should check for the string and if the string is of nine digits or co

Solution 1:

You can simply return from the function when the condition is satisfied:

# Suppose the string is stored in text variableiflen(text) == 9:
    return

Solution 2:

use regex. The below regex will match given that the string contains 9 adjacent digits.

\d{9,}

Solution 3:

to exit a function do you mean to return back from where it was called?

if so then use

iflen(stringVarible)==9:
   return

Post a Comment for "Check If String Is Of Nine Digits Then Exit Function In Python"