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

python check if number contains digit

for number in numbers:
    if '4' in str(number):
        print('{} True'.format(number))
    else:
        print("False")
Comment

how to check if digit in int python

s = set(str(4059304593))
print('2' in s)
Comment

PREVIOUS NEXT
Code Example
Python :: python add list to dictionary in loop 
Python :: django change user password 
Python :: how to save a neural network pytorch 
Python :: how to add column to np array 
Python :: how to read unicode in python 
Python :: discord.py get user input 
Python :: python super init 
Python :: pasal 
Python :: circular array python 
Python :: how to set default user group in django 
Python :: how to pair up two lists in python 
Python :: html to docx python 
Python :: basemap python 
Python :: Python Program to Convert Decimal to Binary, Octal and Hexadecimal 
Python :: python file handling 
Python :: find columns with missing values pandas 
Python :: python check if nan 
Python :: make averages on python 
Python :: how to import a python function from another file 
Python :: how to print python 
Python :: python make file path os 
Python :: sum of positive numbers in array with negative python 
Python :: tdmq python 
Python :: install virtual environment python mac 
Python :: keras tuner 
Python :: plot.barh() group by 
Python :: create close python program in puthon 
Python :: pycairo 
Python :: how to find the number of times a number appears in python 
Python :: internal server error 500 python flask 
ADD CONTENT
Topic
Content
Source link
Name
3+3 =