Slicing = create a sub-string by extracting elements from another string
indexing[ ] or slicing( )
[start:stop:step]
name = "Eric Ramos"
* first_name = name[ : 3] #[0:3]
** last_name = name[5 : ] #[5:0]
*** funky_name = name[ : :2] #[0:end:2]
**** reversed_name = name[ : :-1] #[0:end:-1
*If you want to print just the first name, in this case we already know that computers always start at ZERO.
**You need to know where your string begins, leave it blanket, the computer will read as the very end of your string.
***Depending on the value you set on "step", you gonna print certain characters (1 is default 'cuz will display the first letters)
****You spell the value backwards, just set the "step" as -1
IF YOU DON'T PUT ANYTHING AT THE BEGINNING, COMPUTERS WILL UINDERSTAND AS ZERO, SO YOU CAN SHORTEN YOUR INDEXING
website1 = "https://google.com.br"
website2 = "https://wikipedia.com"
Imagine that we want to remove "https://" and just display "google"
First we need to create a slice object:
slice = slice ( )
within the parentheses we can add up to 3 values (start, stop, step), NOTE THAT THIS TIME YOU SEPARATE THEM WITH COMMA.
EXAMPLE
slice1 = slice( 8,-7 )
HOW TO DISPLAY THIS?
print ( website1 [slice1] )