def string_length(s): """This method counts the amount of characters a given string has.""" # convert string to a list string = list(s) length = 0 # Important to note that we could simply apply this principle by returning # the len of the string in list format but this is easier to visualize. for i in range(1, lf.list_len(string) + 1): length += 1 return length
def string_reverse(s): """This function will reverse any given string.""" # we must first convert the given string into a list. # and create the new String that we will return. string = list(s) newString = "" for i in range(lf.list_len(string)): # -(i + 1) represents the incrementation of the index, i, in reverse order newString = newString + string[-(i + 1)] return newString