String in Python3 can be created using both pairs of singles and double quotes. They are concatenations or secuences of characters, they can be numbers, letters or special characters as long as they are inside the quotes. <\/p>\n
String can be sliced, this means that you can get substrings from a string using the two slice operators:<\/p>\n
Strings can also be used to perform two opperations: <\/p>\n
For example:<\/p>\n
Hello World!<\/p>\n H<\/p>\n llo<\/p>\n !<\/p>\n !dlroW olleH<\/span><\/p>\n Hello World!!!<\/span><\/p>\n Hello World!Hello World!<\/span><\/p>\n <\/p>\n <\/p>\n As you can see String can be seen as lists in some ways. For example the [-1] index points to the last element of the array. <\/span><\/p>\n As you can see the [::-1] gives you the reversed string, but why? Well as I had said if you check lists in Python you will see that its called slicing, and what we are typing is that you will slice the string with a -1 step, this means from the last to the start. <\/p>\n Most of the information was extracted from this page.<\/a><\/p>\n This is my #Mastery26<\/a> of my #TC1014<\/a><\/p>\n<\/div>\n","protected":false},"excerpt":{"rendered":" String in Python3 can be created using both pairs of singles and double quotes. They are concatenations or secuences of characters, they can be numbers, letters or special characters as long as they are inside the quotes. String can be sl… Continue reading >>>str = \"Hello World!\" <\/code><\/p>\n
>>>print (str)<\/code><\/p>\n
>>>print (str[0])<\/code><\/p>\n
>>> print (str[2:5])<\/code><\/p>\n
>>>print (str[-1])<\/code><\/p>\n
>>>Print (str[::-1])<\/code><\/p>\n
>>> Print(str+\"!!\")<\/span><\/code><\/p>\n
>>>Print(str*2)<\/span><\/code><\/p>\n