Appending an id to a list if not already present in a string

前端 未结 8 853
醉话见心
醉话见心 2021-02-02 05:45

I am trying to check if id is in a list and append the id only if its not in the list using the below code..however I see that the id is getting appended even though id is alre

8条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2021-02-02 06:04

    Your id variable is a number where your list only has one element. It's a string that contains your other IDs. You either need to check if id is in that string, or pull the numbers out of the string and store them in the list separately

    list  = [350882, 348521, 350166]
    

提交回复
热议问题