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 :: how to catch ctrl c in python 
Python :: image rotate in python 
Python :: how to save a pickle file 
Python :: python sort two key 
Python :: mouse bottom in pygame 
Python :: manipulate ip address in python 
Python :: create a new dataframe from existing dataframe pandas 
Python :: pyautogui moveTo overtime 
Python :: concatenate dataframes pandas without duplicates 
Python :: how to load wav file with python 
Python :: django createmany 
Python :: python subtract lists 
Python :: convert dict to string python 
Python :: unshorten url python 
Python :: median of a list in python 
Python :: python set and dictionary comprehensions 
Python :: pandas sort by columns 
Python :: run multiple function with multiprocessing python 
Python :: is number python 
Python :: time addition in python 
Python :: basic tkinter gui 
Python :: scipy euclidean distance 
Python :: how to export DataFrame to CSV file 
Python :: python open and read file with 
Python :: strip array of strings python 
Python :: how to convert fahrenheit to celsius in python 
Python :: python reversed range 
Python :: boto3 delete bucket object 
Python :: creating base models django 
Python :: how to start an exe file in python 
ADD CONTENT
Topic
Content
Source link
Name
9+4 =