This is the code I have for the issue. I need to use a random number to add one item to a stack 60% of the time and remove something from the stack 40% of the time and I need to keep track of successful adds and unsuccessful removals.
for i in range(100):
ran = random.randint
random_number = ran
s = 0
us = 0
if random_number < 60:
ll.add()
s += 1
elif random_number > 60:
ll.remove_last()
us += 1
Aucun commentaire:
Enregistrer un commentaire