Рет қаралды 61,815
Python string slice tutorial example explained
#python #slice() #slicing
slicing = create a substring by extracting elements from another string
indexing[] or slice()
[start:stop:step]
name = "Bro Code"
first_name = name[:3] # [0:3]
last_name = name[4:] # [4:end]
funky_name = name[::2] # [0:end:2]
reversed_name = name[::-1] # [0:end:-1]
print(reversed_name)
website1 = "google.com"
website2 = "wikipedia.com"
slice = slice(7,-4)
print(website1[slice])
print(website2[slice])
------------------------------
Up In My Jam (All Of A Sudden) by - Kubbi / kubbi
Creative Commons - Attribution-ShareAlike 3.0 Unported- CC BY-SA 3.0
Free Download / Stream: bit.ly/2JnDfCE
Music promoted by Audio Library • Up In My Jam (All Of A...
------------------------------