Substring

result = my_string[first_index:last_index_plus_one]

result = my_string[3:6]    //Get the characters from index 3 up to index 5 (the last index given is not included)

result = my_string[:6]    //Get all the characters up to index 5 (the last index given is not included)

result = my_string[3:]    //Get the characters from index 3 up to the end of the string

result = my_string[-2:]    //Get the last 2 characters of the string

result = my_string[:-2]    //Get the string excluding the last 2 characters

Convert string to value

#string to int
my_variable = int(my_string)

#string to float
my_variable = float(my_string)
Feel free to comment if you can add help to this page or point out issues and solutions you have found. I do not provide support on this site, if you need help with a problem head over to stack overflow.

Comments

Your email address will not be published. Required fields are marked *