I'm new to Python. I want to print elements in the list without duplicate in a specific format: {"id": value}. Here is my code.
d =['l','o','u','l','b','l','a']
for item in range(0,len(d)):
  prev=item-1
  if item==0:
    print("  {\"id\": \"" + (d[item]) + "\"} ,") 
    continue
  if (d[item]==d[prev])or(d[item] in d[:prev]):
    continue
  else:
    print("  {\"id\": \"" + (d[item]) + "\"}"),
    if (item==(len(d))): #if last element, print  ".", else print ","
        print(".\n"),
    else:
        print(",\n"),
The result should be:
  {"id": "l"} ,
  {"id": "o"} ,
  {"id": "u"} ,
  {"id": "b"} ,
  {"id": "a"} .
But the output is:
  {"id": "l"} ,
  {"id": "o"} ,
  {"id": "u"} ,
  {"id": "b"} ,
  {"id": "a"} ,
My code works well until the last line. It ends with "," instead of ".". Please help me
 
     
     
     
     
    