diff --git a/guide/english/python/exception-and-error-handling/index.md b/guide/english/python/exception-and-error-handling/index.md index ceedeb1eb8..8877667fcd 100644 --- a/guide/english/python/exception-and-error-handling/index.md +++ b/guide/english/python/exception-and-error-handling/index.md @@ -10,24 +10,26 @@ To solve this problem in python we can use `try` and `except` Example: -```shell ->>> try: ->>> . . . print "this is not a string "+1 ->>> except: ->>> . . . print "error" -error -``` -and if you want to get error messages in more detail from your code, you can add arguments `except Exception as err` +```python +try: + print("this is not a string " + 1) +except: + print("error") -```shell ->>> try: ->>> . . . print "this is not a string "+1 ->>> except Exception as err: ->>> . . . print "error:\n"+str(err) -error: -cannot concatenate 'str' and 'int' objects +>>> error +``` +And if you want to get error messages in more detail from your code, you can add arguments `except Exception as err` + +```python +try: + print("this is not a string " + 1) +except Exception as err: + print("error:\n" + str(err)) + +>>> error: +>>> must be str, not int ``` More Information: -Errors and Exceptions documentation. +Errors and Exceptions documentation.