I have the following code.
for a in range(0,len(customer_name),1): url = "https://whatever_my_url_is.com/" + customer_name[a] + "/" try: page = urllib.request.urlopen(url) except: print("Cannot load page, bad URL.") a = a + 1 rest of my code
What it currently does:
- Goes through each customer, one at a time, and loads their page.
- If the URL is bad, I get the "Cannot load page, bad URL." message.
- The rest of my code continues like normal.
What I want it to do is immediately stop what it's doing and move to the next customer_name
on the list, NOT continue the rest of the code.
Any suggestions?
https://stackoverflow.com/questions/66084162/python-for-statement-increment-and-skip-the-rest-of-the-code February 07, 2021 at 11:03AM
没有评论:
发表评论