Answers for "python return endswith string"

1

endswith python

#endswith() function: the function of string which returns the value matching 
#the argument or else returns nothing.
example: to check if the given email matches the domain of the sample email.

 a=input('enter email ID :')
if a.endswith('@draken.com'): # here suffix should come @draken.com prefix independent
 print('valid Email ID')
else:
 print('not valid Email ID')
#output
--------------------------------------------------------------------------------------
enter email ID :[email protected]
valid Email ID
--------------------------------------------------------------------------------------
enter email ID :[email protected]
not valid Email ID
--------------------------------------------------------------------------------------
Posted by: Guest on January-20-2022
3

python string ends with

#!/usr/bin/python

str = "this is string example....wow!!!";

suffix = "wow!!!";
print str.endswith(suffix)
print str.endswith(suffix,20)

suffix = "is";
print str.endswith(suffix, 2, 4)
print str.endswith(suffix, 2, 6)
Posted by: Guest on March-28-2020

Python Answers by Framework

Browse Popular Code Answers by Language