0

Problem Statement :

By using list comprehension, please write a program to print the list after removing delete numbers which are divisible by 5 and 7 in [12,24,35,70,88,120,155,140]

myList = [12,24,35,70,88,120,155,140]

for i in myList :
  y = i
  print (y)
  if i % 5 == 0 and i % 7 == 0 :
      myList.remove(i)

print(myList)

Why 70 is not printed while execution print(y) command and why 70 was not removed from the list [1]: https://i.stack.imgur.com/K7dj0.jpg

Samwise
  • 51,883
  • 3
  • 26
  • 36

0 Answers0