__#define list of numbers
numbersList = [4, 12, 35, 13, 8, 13, 0, 2, 13, 13, 56]
def removeUnlucky():
print("Unlucky: ",numbersList
)removeUnlucky(numbersList
)print("Lucky: ", numbersList)
Complete the function removeUnlucky(). the program will not run because the function is incomplete. remove every instance of the number 13 from the list. output is:
Unlucky: [4, 12, 35, 13, 8, 13, 0, 2, 13, 13, 56]
Lucky: [4, 12, 35, 8, 0, 2, 56]
numbersList = [4, 12, 35, 13, 8, 13, 0, 2, 13, 13, 56] def removeUnlucky(lst): i = 0 while i < len(lst): if lst[i] == 13: lst.pop(i) i -= 1 i += 1 print("Unlucky: ", numbersList) removeUnlucky(numbersList) print("Lucky: ", numbersList)
Get Answers For Free
Most questions answered within 1 hours.