From 035bde72efe049b4a316464c189778a2f110f23a Mon Sep 17 00:00:00 2001 From: Yukti Khosla <44090430+Yukti-09@users.noreply.github.com> Date: Tue, 21 Jul 2020 20:03:45 +0530 Subject: [PATCH] Create else_without_if.txt Most languages do not allow an else statement without an if. However, python allows the else statement to be executed without the if provided the loop before it has not been terminated by a break statement. --- else_without_if.txt | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 else_without_if.txt diff --git a/else_without_if.txt b/else_without_if.txt new file mode 100644 index 0000000..83f809d --- /dev/null +++ b/else_without_if.txt @@ -0,0 +1,12 @@ +i = 0 +while i<=5: +print(i,end=' ') +i += 1 +else: +print(i,end=' ') + +OUTPUT: +0 1 2 3 4 5 6 + +Most languages do not allow an else statement without an if. +However, python allows the else statement to be executed without the if provided the loop before it has not been terminated by a break statement.