""" Purpose: introduce string slicing """ # Get string of choice s = input( "Enter favorite pie: " ) # Get indices i and j t = input( "Enter two indices i and j: " ) i, j = t.split() i = int( i ) j = int( j ) # Get slices of s slice1 = s[ i : j ] # Substring starts at index i, ends at index j-1 slice2 = s[ i : ] # Substring starts at index i, continues to end of string slice3 = s[ : j ] # Substring starts at index 0, ends at index j-1 slice4 = s[ : ] # Substring equals the entire string # Print results print() print( "s[ i : j ]:", slice1 ) print( "s[ i : ]:", slice2 ) print( "s[ : j ]:", slice3 ) print( "s[ : ]:", slice4 )