+ 1

Why "NONE" is come when my stack is print?.Please following code invoke in some other IDE for better experience it's my request.

class stack: def __init__(self): self.item=[] def is_empty (self): return self.item==[] def push (self, data): self.item.append(data) def pop(self): return self.item.pop() def display (self): x=s.item print (x,end="") s=stack() while True: print ("what do you want to do, 1=push, 2=pop, 3=exit") operation =int(input()) if operation==1: print ("how many element do you want to enter") number=int(input()) for I in range (number): s.push(int(input("enter the value: "))) print (s.display()) elif operation==2: if s.is_empty(): print ("stack is empty\n") else: print ("popped value is :",s.pop()) elif operation ==3: print ("Thank you!\n") break else: print ("please enter valid value\n")

7th Mar 2022, 10:23 AM
jayrv_7_
3 Respostas
- 2
s.display () not returning anything.. So just put s.display () Instead of print(s.display())
7th Mar 2022, 10:37 AM
Jayakrishna 🇮🇳
0
7th Mar 2022, 10:45 AM
jayrv_7_
0
jayrv_7_ Next time share code link by saving in playground, pls.. See post by @jay sir to know how to share. You're welcome..
7th Mar 2022, 10:57 AM
Jayakrishna 🇮🇳