97200/how-to-print-an-exception-in-python
Here is my code:
try: something here except: print('the whatever error occurred.')
How can I print the error/exception in my except: block?
Hello @kartik,
For Python 2.6 and later and Python 3.x:
except Exception as e: print(e)
For Python 2.5 and earlier, use:
except Exception,e: print str(e)
Hope it helps!!
Thank you!!
For Python 2.6 and later and Python ...READ MORE
Python doesn't have a native array data ...READ MORE
class Solution: def firstAlphabet(self, s): self.s=s k='' k=k+s[0] for i in range(len(s)): if ...READ MORE
Hey @abhijmr.143, you can print array integers ...READ MORE
You can also use the random library's ...READ MORE
Syntax : list. count(value) Code: colors = ['red', 'green', ...READ MORE
Enumerate() method adds a counter to an ...READ MORE
You can simply the built-in function in ...READ MORE
print(*names, sep = ', ') This is what ...READ MORE
Hello, To import an updated package while in ...READ MORE
OR
At least 1 upper-case and 1 lower-case letter
Minimum 8 characters and Maximum 50 characters
Already have an account? Sign in.