The lid is the unique id of that mylist entry across ALL mylist entries. Aka new mylist entries are given numbers over 6 million atm.
The documentation says:
COMMAND STRING:
by lid: (mylist id)
MYLIST lid={int4 lid}
by fid:
MYLIST fid={int4 fid}
by size+ed2k hash:
MYLIST size={int4 size}&ed2k={str ed2khash}
REPLY:
221 MYLIST
{int4 lid}|{int4 fid}|{int4 eid}|{int4 aid}|{int4 gid}|{int4 date}|{int2 state}|{int4 viewdate}|{str storage}|{str source}|{str other}
OR
321 NO SUCH ENTRY
Aka, you always get the correct lid in the reply from the udp api. To get a lid in the first place you need to ask via either an ed2k link or a file id.
To get a list of all mylist entries you need to use the TCP API.
Note, the for loop above is an example of things you should NOT do with the UDP api, it's heavy as hell on anidb and might get you blocked.