Strings are sequences of characters that can be enclosed in single quotes, double quotes, or triple quotes. Strings have indexes that allow accessing individual characters and slicing strings. Common string methods allow changing case, counting/finding substrings, splitting strings, concatenating strings, and checking string properties.
Strings are sequences of characters that can be enclosed in single quotes, double quotes, or triple quotes. Strings have indexes that allow accessing individual characters and slicing strings. Common string methods allow changing case, counting/finding substrings, splitting strings, concatenating strings, and checking string properties.
Strings are sequences of characters that can be enclosed in single quotes, double quotes, or triple quotes. Strings have indexes that allow accessing individual characters and slicing strings. Common string methods allow changing case, counting/finding substrings, splitting strings, concatenating strings, and checking string properties.
Strings are sequences of characters that can be enclosed in single quotes, double quotes, or triple quotes. Strings have indexes that allow accessing individual characters and slicing strings. Common string methods allow changing case, counting/finding substrings, splitting strings, concatenating strings, and checking string properties.
1. Strings are sequence of characters enclosed within single, double or
triple quotes. ' ' " " ''' ''' eg: my_string = "Hello world" first index = 0 my_string[0] // 'H' last index = -1 my_string[-1] // 'd' my_string[0:5] // Hello my_string[0:5:2] // skip 1 letter Hlo my_string[1:] // ello world
2. length of string = len(my_string)
3. string to lowercase = my_string.lower() 4. string to uppercase = my_string.upper() 5. replace a substring = my_string.replace('H', 'F') 6. number of occurences of substring = my_string.count("l") # return 3 => it will count the substring repeated by no of times (l -> 3) 7. finding index of substring = my_string.find("world"); # 6
8. splitting a string = fruit = " i like html java python"
fruit.split(' ') [ 'i', 'like', 'html', 'java', 'python' ] 9. str ="test" str*3 10. concatenation str+"good" 11. string_name.islower() : returns boolean value if it is in lower or upperCase 12. in or not in