my_list = ['orchids','chamber','phoenix','central','juggler','dungeon','passive', 'capable','creator','rabbits','succeed','compute','achieve','attempt', 'network','address','supreme','believe','concern','explore','finance', 'benifit','license','carcass','abalone','morning','abandon','macabre', 'teacher','billion','yankees','mistake','suspect','barrack','connect', 'operate','cabbage','ability','rushing','passion','perfect','fashion', 'outputs','success','banking','journal'] # a) Write python code below that does
Fantastic news! We've Found the answer you've been seeking!
Question:
my_list = | |
['orchids','chamber','phoenix','central','juggler','dungeon','passive', | |
'capable','creator','rabbits','succeed','compute','achieve','attempt', | |
'network','address','supreme','believe','concern','explore','finance', | |
'benifit','license','carcass','abalone','morning','abandon','macabre', | |
'teacher','billion','yankees','mistake','suspect','barrack','connect', | |
'operate','cabbage','ability','rushing','passion','perfect','fashion', | |
'outputs','success','banking','journal'] | |
# a) Write python code below that does the following: | |
# for each digit in 12345, remove the corresponding item from the list above. | |
# As an example, if your MY_NUM is 10233, then you will remove the following | |
# items from the list above: chamber (index 1), orchids (index 0), | |
# phoenix (index 2), and central (index 3). | |
# Once completed, my_list should have fewer items. | |
# Note: your approach for item removal should be based on the items | |
# as determined from the ORIGINAL UNMODIFIED list -- in this example, those | |
# words are: chamber, orchids, phoneix, and central. Make sure the correct | |
# words are getting removed. | |
# b) Write python code below that does the following: | |
# Now that my_list has fewer items, compute the number of words from my_list | |
# where the first or last letter matches at least one of the letters of | |
# Chamber. The count should be set in a variable named my_count. It is | |
# initialized to 0 below. | |
my_count = 0 | |
############################################################################### | |
# please do not modify these last few lines. They will be used to evaluate your | |
# exam. If you have used any print statements in your own code, please comment | |
# them out. | |
orig_list = | |
['orchids','chamber','phoenix','central','juggler','dungeon','passive', | |
'capable','creator','rabbits','succeed','compute','achieve','attempt', | |
'network','address','supreme','believe','concern','explore','finance', | |
'benifit','license','carcass','abalone','morning','abandon','macabre', | |
'teacher','billion','yankees','mistake','suspect','barrack','connect', | |
'operate','cabbage','ability','rushing','passion','perfect','fashion', | |
'outputs','success','banking','journal'] | |
print(f'Q2:my_list:{len(my_list)}:{set(orig_list)-set(my_list)}') | |
print(f'Q2:my_count:{my_count}') |
Posted Date: