How to check whether a string ends with another string in Python

3 Answers

0 votes
s = "python java c c++ php"
       
if (s.endswith('php')) :
    print("yes")
else:
    print("no")


 
 
'''
run:
 
yes
 
'''

 



answered Nov 16, 2019 by avibootz
0 votes
string_A = "python java c c++ php"

string_B = "php"

print(string_A.endswith(string_B))



'''
run:

True

'''

 



answered Jun 11, 2023 by avibootz
0 votes
string_A = "python java php c c++ php"

string_B = "php"

# stringA.endswith(stringB, start, end)

print(string_A.endswith(string_B, 11, 15))



'''
run:

True

'''

 



answered Jun 11, 2023 by avibootz

Related questions

3 answers 245 views
1 answer 162 views
1 answer 139 views
1 answer 168 views
1 answer 134 views
3 answers 212 views
...