Programming Tip -How to handle exception inside a Python for loop?
Today i am going to show Programming Tip - How to handle exception inside a Python for loop
with simple code. I hope you will understand this.
If you have any query you can ask.
i hope you will like it.
This doesn't cause any issues. For example,
for i in range(5):
try:
if i % 2 == 0:
raise ValueError("some error")
print(i)
except ValueError as e:
print(e)
This will give the output
some error
1
some error
3
some error
Follow me at : https://steemit.com/@ahmadhassan
=========================================================
Thanks for reading and always welcome your suggestions :) =========================================================
This post has received a 1.30 % upvote from @booster thanks to: @ahmadhassan.