Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

split a given number in python

# split a given int value in list
num = 13579
x = [int(a) for a in str(num)]
print(x)
Comment

python how to split a number

number = "12345"
result = []
for digit in number:
    result.append(digit)
print(result)
# result is ['1', '2', '3', '4', '5']
Comment

how to separate numbers from a string in python

#can be done through regex library
import re
some_string = '31 Kaiser Friedrich Avenue'
#use the findall() method to find number within the string
#the ‘d+’ would help find digits
num = re.findall(r'd+', some_string)
print(num)
# result would be ['31']
Comment

PREVIOUS NEXT
Code Example
Python :: python check folder exists 
Python :: python pandas remove non-numeric characters from multiple columns 
Python :: how to 404 custom page not found in django 
Python :: extract url from page python 
Python :: with urllib.request.urlopen("https:// 
Python :: python remove new line 
Python :: python3 yyyymmddhhmmss 
Python :: R write dataframe to file 
Python :: python write file 
Python :: how to convert string date to timestamp in python 
Python :: remove rows from pandas dataframe that have text 
Python :: python find closest lower value in list 
Python :: videofield django 
Python :: using tqdm in for loop 
Python :: python kill process by name 
Python :: how to underline text in tkinter 
Python :: find record where dataframe column value contains 
Python :: python save output to file 
Python :: register model in admin django 
Python :: python randomly chose user agent 
Python :: unix command in python script 
Python :: convert dict to dataframe 
Python :: how to use print in python 
Python :: python - iterate with the data frame 
Python :: python detect lines 
Python :: arch linux python 3.7 
Python :: download images python google 
Python :: python fibonacci 
Python :: pyspark join 
Python :: how to use xpath with beautifulsoup 
ADD CONTENT
Topic
Content
Source link
Name
4+7 =