Back

Explore Courses Blog Tutorials Interview Questions
0 votes
1 view
in Python by (12.7k points)

To recognize whether a python string closes with a specific substring, say ".txt", there is an advantageous built-in python string method;

if file_string.endswith(".txt"): 

I might want to distinguish whether a python string starts with a specific substring, say "begin_like_this". I'm not capable locate/find a helpful method that I can utilize this way;

if file_string.beginswith("begin_like_this"):

Im actually using python version 3.6

1 Answer

0 votes
by (26.4k points)

You are actually looking for str.startswith

if file_string.startswith("begin_like_this"):

Are you looking for a good python tutorial? Join the python course fast and gain more knowledge in python.

To know more about this you can have a look at the following video tutorial:-

Related questions

0 votes
1 answer
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer

Browse Categories

...