[Solved] understanding “try” and “except” python


basically a try and except is like an if and else…kinda

except that when you try if it doesn’t raise an exception it excecutes the try code block but when it fails it’ll execute the except block for example

a = [1,2,3,4,"hello"]

for i in a:
    try:
        print(i)
        i + 1

    except:
        print("nope " + i  + " is a string")

solved understanding “try” and “except” python