#Kevin Solis Gomez
#October 27, 2022
#Module 8 Section 1.2
#Today I learned how to slice strings up.
# [ ] review and run example
# assign string to student_name
student_name = "Colette"
# addressing the 3rd, 4th and 5th characters using a slice
print("slice student_name[2:5]:",student_name[2:5])
# [ ] review and run example
# assign string to student_name
student_name = "Colette"
# addressing the 3rd, 4th and 5th characters individually
print("index 2, 3 & 4 of student_name:", student_name[2] + student_name[3] + student_name[4])
# [ ] review and run example
long_word = 'Acknowledgement'
print(long_word[2:11])
print(long_word[2:11], "is the 3rd char through the 11th char")
print(long_word[2:11], "is the index 2, \"" + long_word[2] + "\",", "through index 10, \"" + long_word[10] + "\"")
# [ ] slice long_word to print "act" and to print "tic"
long_word = "characteristics"
print(long_word[4:7],'and',long_word[11:14])
# [ ] slice long_word to print "sequence"
long_word = "Consequences"
print(long_word[3:11])
# [ ] review and run example
student_name = "Colette"
# addressing the 1st, 2nd & 3rd characters
print(student_name[:3])
# [ ] print the first half of the long_word
long_word = "Consequences"
print(long_word[:6])
# [ ] print a message that there is "No Parking" on index 0 or index 4 streets
print('No parking in street '+long_word[0],'and street '+long_word[4])
# [ ] review and run example
student_name = "Colette"
# 4th, 5th, 6th and 7th characters
student_name[3:]
# [ ] print the second half of the long_word
long_word = "Consequences"
print(long_word[6:])
# [ ] print a message that there is "No Parking" on index 0 or index 4 streets
print('No parking in street '+long_word[0],'and street '+long_word[4])
# [ ] review and run example
student_name = "Colette"
# return all
print(student_name[:])
# [ ] review and run example
student_name = "Colette"
# return every other
print(student_name[::2])
# [ ] review and run example
student_name = "Colette"
# return every third, starting at 2nd character
print(student_name[1::2])
# [ ] review and run example
long_word = "Consequences"
# starting at 2nd char (index 1) to 9th character, return every other character
print(long_word[1:9:2])
# [ ] print the 1st and every 3rd letter of long_word
long_word = "Acknowledgement"
long_word[0::3]
# [ ] print every other character of long_word starting at the 3rd character
long_word = "Acknowledgement"
print(long_word[2::2])
# [ ] review and run example of stepping backwards using [::-1]
long_word = "characteristics"
# make the step increment -1 to step backwards
print(long_word[::-1])
# [ ] review and run example of stepping backwards using [6::-1]
long_word = "characteristics"
# start at the 7th letter backwards to start
print(long_word[6::-1])
# [ ] reverse long_word
long_word = "stressed"
long_word[::-1]
# [ ] print the first 5 letters of long_word in reverse
long_word = "characteristics"
long_word[4::-1]
# [ ] print the first 4 letters of long_word
# [ ] print the first 4 letters of long_word in reverse
# [ ] print the last 4 letters of long_word in reverse
# [ ] print the letters spanning indexes 3 to 6 of long_word in Reverse
# - note all 4 of these requirements will have 4 characters displayed
long_word = "timeline"
print(long_word[:4])
print(long_word[3::-1])
print(long_word[7:3:-1])
print(long_word[6:2:-1])