Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

check if string has digits python

string = 'this string has digits 12345'
if any(char.isdigit() for char in string):
  #digits found
  print('"{}" has digits!'.format(string))
else:
  #digits NOT found
  print('"{}" does NOT have digits!'.format(string))
Comment

how to check how many digits string has in python

s = 'some string'

numbers = sum(c.isdigit() for c in s)
letters = sum(c.isalpha() for c in s)
spaces  = sum(c.isspace() for c in s)
others  = len(s) - numbers - letters - spaces
Comment

PREVIOUS NEXT
Code Example
Python :: python key from values 
Python :: install apriori package python 
Python :: append data to column in pan 
Python :: change the side of the axis plt python 
Python :: get unique values from a list 
Python :: append a list to a list python 
Python :: django rest framework viewset perform_update 
Python :: count number items in list python 
Python :: check status code urllib open 
Python :: swapping variables in python 
Python :: raspistill timelapse 
Python :: python crash course 
Python :: python how to align text writen to a file 
Python :: how to plot in python 
Python :: seaborn angle lable 
Python :: pandas read csv without scientific notation 
Python :: logarithms python 
Python :: install python windows powershell 
Python :: get the invite url of server disc.py 
Python :: python .format 
Python :: K-Means Clustering in Python – 3 clusters 
Python :: message handler python telegram bot example 
Python :: check if variable is empty python 
Python :: python sort multiple keys 
Python :: register admin django 
Python :: get method in python dictionary 
Python :: python timedelta years 
Python :: urllib.request.urlopen with headers 
Python :: uninstall a python package from virtualenv 
Python :: capitalize python 
ADD CONTENT
Topic
Content
Source link
Name
6+3 =