-1

I'm doing a robotic competition and I had a simple request.

This is a simplified analogue of what I have:

import random


dumping_list=[]
while True:
    markers = [#a list that could range in length from many to no elements]


    if len(markers) != 0:
        #do some stuff


    elif len(markers) == 0:
        dumping_list.append(markers[0])

Now my question is, how can make the markers[0] in the elif refer to the markers[0] the last time that it contained something, how do I go about that?

Any help would be brilliant! Thanks

jamylak
  • 128,818
  • 30
  • 231
  • 230
user2137452
  • 143
  • 1
  • 4
  • 7

1 Answers1

0

I'm not sure if I understand what you're trying to accomplish here, but I think that could help

import random
dumping_list=[]
last_makers = None

while True:
    markers = [#a list that could range in length from many to no elements]


    if len(markers) != 0:
        #do some stuff
        last_maker = makers[0]


    elif len(markers) == 0:
        if last_makers:
            dumping_list.append(last_makers)
Gricha
  • 1,044
  • 3
  • 11
  • 26