python - Why are variables assigned to empty brackets before use? -
python - Why are variables assigned to empty brackets before use? -
def substitute(clues,words): subst_words = [] # <== here in range(len(words)): word = words[i] j in range(len(clues)): word = word.replace(clues[j][1],clues[j][0]) subst_words.append(word) homecoming subst_words
why subst_words assigned empty pair of brackets before use? stupid question know unsure... additionally how apply tuple in substitution of list, if @ possible?
the variable beingness initialized list.
uninitialized variables can lead resource bugs
if had not been declared not accessible. if had been declared initialized none, not able utilize append function on it.
also, beingness declared in outermost scope of function. meaning curly braces nested farther within function have access variable. had been declared within loop illustration not able access outside of loop.
python variables
Comments
Post a Comment