Try or Except Structure in Python Get link Facebook X Pinterest Email Other Apps CODE: astr= 'Hello bob' try: istr= int(astr) except: istr = -1 print('First', istr) bstr='123' try: jstr= int(bstr) except: jstr = -1 print('Second', jstr) OUTPUT: First -1 Second 123 Get link Facebook X Pinterest Email Other Apps Comments
Comments
Post a Comment