Search code examples
pythonpython-3.xlisttwittertweepy

how to jump a list member in python?


so I'm trying to send i message to a group of people . I want to know how can I jump to 'test2' (next list member ) if 'test1' (current list member ) got an error .

profile_id = ['test1','test2']
for ids in profile_id:
    api.send_direct_message(ids,text)

Solution

  • as Menashe already said, you can use TRY, EXCEPT and PASS. like this:

    profile_id = ['test1','test2']
    for ids in profile_id:
        try:
           api.send_direct_message(ids,text)
        except:
           pass