This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: OUTPUT WRONG
Type: behavior Stage: resolved
Components: Versions: Python 3.10, Python 3.9, Python 3.8, Python 3.7, Python 3.6
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: Kkshitish, christian.heimes
Priority: normal Keywords:

Created on 2021-01-15 08:32 by Kkshitish, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
main.py Kkshitish, 2021-01-15 08:32
Messages (2)
msg385100 - (view) Author: Kshitish Kumar (Kkshitish) Date: 2021-01-15 08:32
try:
  
  a = 10
  
  if a == 11:
    
    print ("Yes")
    
except:
  
  print ("Out")
  
else:
  
  print ("No")


Output: No

The output should be "Out" but it print "No", The else statement should be print when try condition is execute. But the try condition is not execute on program. But still it print else statement. 

This is not ideal output. If you are disagree with me. So, kindly provide very strong argument over this.
msg385101 - (view) Author: Christian Heimes (christian.heimes) * (Python committer) Date: 2021-01-15 08:47
"No" is the correct output for your code example. Your code does not raise an exception, therefore the else block is executed.

Please don't use the bug tracker to get assistance with learning Python. There are community resources like chat and forums dedicated to that, https://www.python.org/community/
History
Date User Action Args
2022-04-11 14:59:40adminsetgithub: 87099
2021-01-15 08:47:03christian.heimessetstatus: open -> closed

type: security -> behavior

nosy: + christian.heimes
messages: + msg385101
resolution: not a bug
stage: resolved
2021-01-15 08:32:18Kkshitishcreate