
delimiter = '_*_'
mylist = ['Brazil', 'Russia', 'India', 'China'] print delimiter.join(mylist)
$ python str_methods.py
Yes, the string starts with "Swa" Yes, it contains the string "a" Yes, it contains the string "war" Brazil_*_Russia_*_India_*_China
Here, we see a lot of the string methods in action. The startswith method is used to find out whether the string starts with the given string. Thein operator is used to check if a given string is a part of the string.
The find method is used to do find the position of the given string in the string or returns -1 if it is not successful to find the substring. Thestr class also has a neat method tojoin the items of a sequence with the string acting as a delimiter between each item of the sequence and returns a bigger string generated from this.
Describe what you're looking for in as much detail as you'd like.
Our AI reads your request and finds the best matching books for you.
Popular searches:
Join 2 million readers and get unlimited free ebooks