import re
s = "12 hello 52 19 some random 15 number"
# Extract numbers and cast them to int
list_of_nums = map(int, re.findall('d+', s))
print list_of_nums
print(str(1)) # convert number to string
print(int("1")) # convert string to int
print(float(1)) # convert int to float
print(list('hello')) # convert string to list
print(tuple('hello')) # convert string to tuple
print(list((1, 2, 3))) # convert tuple to list
print(tuple([1, 2, 3])) # convert list to tuple
print(bool(1)) # convert a number to boolean
print(bool(0)) # convert a number to boolean
print(bool("")) # convert a string to boolean
print(bool("data")) # convert string to boolean
print(bin(10)) # convert an integer to a binary string
print(hex(10)) # convert an integer to a hex string
print(oct(10)) # convert an integer to an octal string
how to change an integer to a string in python permanently
# Define a variable containing an integer first
number = 7
# Next, we would have to convert it to a string. But, since the str() method
# would make our variable's integer a string for a temporary period,
# we would have to REdefine the entire variable as a string:
number = str(number)
# To prove my method, I will use the type() function to show you that
# the variable had change permanently:
print(type(number))
>>output: <class 'str'>