Paul McGuire @[email protected] · activity timestamp 10 hours ago In retrospect, I should have known better than to do this, but I was hoping to avoid making a temporary copy. (SPOILER on why not in the replies) #python #gotchas Read more Read less Translate alt Python code illustrating a Python list gotcha: def get_possible_words(): return "YES NO Y N".split() possible_yes_no = get_possible_words() # add lower case options possible_yes_no.extend( wd.lower() for wd in possible_yes_no # <-- don't do this ) Python code illustrating a Python list gotcha: def get_possible_words(): return "YES NO Y N".split() possible_yes_no = get_possible_words() # add lower case options possible_yes_no.extend( wd.lower() for wd in possible_yes_no # <-- don't do this ) Reply 2 Boost Quote You cannot quote this post Like More actions Copy link Flag this post Block
alt Python code illustrating a Python list gotcha: def get_possible_words(): return "YES NO Y N".split() possible_yes_no = get_possible_words() # add lower case options possible_yes_no.extend( wd.lower() for wd in possible_yes_no # <-- don't do this ) Python code illustrating a Python list gotcha: def get_possible_words(): return "YES NO Y N".split() possible_yes_no = get_possible_words() # add lower case options possible_yes_no.extend( wd.lower() for wd in possible_yes_no # <-- don't do this )