Converting a loop with an assignment into a comprehension

Converting a loop into a comprehension is simple enough: mylist = [] for word in ['Hello', 'world']: mylist.append(word.split('l')[0]) to mylist = [word.split('l')[0] for word in ['Hello', 'world']] But I’m not sure how to proceed when the loop involves assigning a value to a reference. mylist = [] for word in ['Hello', 'world']: split_word = word.split('l') … Read more