Below is the code to return either a VIP customer or an ordinary customer, the list does not take vip as a False value and always takes True.
Class DonutQueue(): def arrive(self,name,VIP): self.name = name self.vip = VIP if self.vip==True: self.queue2.append(self.name) return self.queue2 else: self.queue.append(self.name) return self.queue def next_customer(self): while not self.queue2== []: if not self.queue2==[]: return self.queue else: return self.queue2 def main(): n = int(input("Enter the number of customers you want to add")) for i in range(0,n): name = input("Enter their name") vip= bool(input("Are they a VIP")) DonutQueue.arrive(name,VIP) print (DonutQueue().next_customer()) Below is the output:
Enter the number of customers you want to add2 Enter their name John Are they a VIP False Enter their name Wick Are they a VIP True None Why am I getting None as the output and my value always takes True when I input False.
Below is the debugger values:
i:0 n:2 name: John vip: True https://stackoverflow.com/questions/66718292/my-vip-variable-does-not-take-false-as-a-value-and-always-defaults-to-true March 20, 2021 at 12:38PM
没有评论:
发表评论