rsplit()

rsplit() returns a list after breaking a string using delimiter and max value
my_str.rsplit(delimiter,max_value) 
delimiter : to be used to break the string
max_value : optional , the number of elements in output plus one. Default value is -1 so it includes all occurance.
my_list="'Alex','Ronald','John'"
my_list=my_list.rsplit(',')
print(my_list)
output
["'Alex'", "'Ronald'", "'John'"]
Without delimiter
my_list="'Alex','Ronald','John'"
my_list=my_list.rsplit()
print(my_list)
["'Alex','Ronald','John'"]
If delimiter is not found
my_list="'Alex','Ronald','John'"
my_list=my_list.rsplit('*')
print(my_list)
Output
["'Alex','Ronald','John'"]
Using one email address to separate domain and userid part
my_list="userid@example.com"
my_list=my_list.rsplit('@')
print(my_list)
Output
['userid', 'example.com']
All String methods



plus2net.com



Post your comments , suggestion , error , requirements etc here




We use cookies to improve your browsing experience. . Learn more
HTML MySQL PHP JavaScript ASP Photoshop Articles FORUM . Contact us
©2000-2020 plus2net.com All rights reserved worldwide Privacy Policy Disclaimer