I am quite confused when using functions with strings. Sometimes I need to set an input in a different variable (example 1) for the function to work, and others I just write the input directly within the function (example 2). Why?
def get_length(word): counter = 0 for i in word: counter += 1 return counter word = "codecademy" length = get_length(word) print(length)
def letter_check(word, letter): for character in word: if character == letter: return True return False print(letter_check("strawberry", "a")) print(letter_check("strawberry", "o"))