I am getting list.remove(x) error so what am I doing here is that, am using this program to generate random numbers without duplicates from a set range and removing the number as the number has been called but somehow I am getting not in the list message even though the random has been called from the list.
import random
def checkPizza(numOfPizza):
pizzaD = []
allowed_val = list(range(0,M+1))
if numOfPizza == 2:
allowed_val = allowed_val
while True:
allowed_val = allowed_val
alpha = random.choice(allowed_val)
beta = random.choice(allowed_val)
if alpha != beta:
allowed_val.remove(alpha)
allowed_val.remove(beta)
pizzaD.append(alpha)
pizzaD.append(beta)
break
I guess if any one can help me in this case ... i know it is kind of noob but I`m new to programming so
Aucun commentaire:
Enregistrer un commentaire