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", "123"))
Even if we change letter, word and character’s spelling in code, I still get the output. So it’s not inbuilt keyword like str,len, def or something. So how does python understand what we meant by character equal to letter. And it is not explained anywhere in exercise.
#remove_middle def remove_middle(lst, start, end): return lst[:start] + lst[end+1:] #Uncomment the line below when your function is done print(remove_middle([4, 8, 15, 16, 23, 42], 1, 4))
Same with this code. I am having difficulty in understanding similar codes. I tried changing function arguments lst, start, end with other words and code still runs fine. My question is same, how python knows, which one is list and how end & start strings are used as indexes? it has anything to do with number of arguments we use while defining function like 3 arguments creates list… first for list, second for starting index and last for ending index? Can anyone explain syntax for above codes… it would be really helpful.