Saved Bookmarks
| 1. |
Write a function in Python PUSH(Arr), where Arr is a list of numbers. From this list push all numbers divisible by 5 into a stack implemented by using a list. Display the stack if it has at least one element, otherwise display appropriate error message. |
|
Answer» Using of any correct code giving the same result is also accepted. def PUSH(Arr,value): s=[] for x in range(0,len(Arr)): if Arr[x]%5==0: s.append(Arr[x]) if len(s)==0: print("Empty Stack") else: print(s) |
|