Python inbuilt Functions 8

isdecimal()

The isdecimal() method returns True if all the characters are decimals (0-9).

Syntax
string.isdecimal()

n="12345"
print(n.isdecimal())

n="abcd12345"
print(n.isdecimal())

n="12345abcd"
print(n.isdecimal())

n="12aa345"
print(n.isdecimal())
#Output

True
False
False
False

join()

The join() method takes all items in an iterable and joins them into one string.
A string must be specified as the separator.

Syntax
string.join(iterable)

iterable: Required. Any iterable object where all the returned values are strings

n=("abc","pqr","xyz")
n1="#".join(n)
print(n1)

n=("abc","pqr","xyz")
n1="Computer".join(n)
print(n1)

n=("abc","pqr","xyz")
n1="***".join(n)
print(n1)

n=("abc","pqr","xyz")
n1="*".join(n)
print(n1)
#Output

abc#pqr#xyz
abcComputerpqrComputerxyz
abc***pqr***xyz
abc*pqr*xyz

Visitor Counter

0051050