Can we use else with for loop in python?
Answer / Sumit Kudesia
No, Python does not support an 'else' clause within a 'for' loop. The 'else' statement in Python is used as part of conditional statements such as 'if', 'elif', and 'else'. It gets executed if the loop finishes naturally (i.e., without being terminated by a break statement).
| Is This Answer Correct ? | 0 Yes | 0 No |
What is python web application framework?
What is a repl in python?
How does python compare string and int?
What is python rest api?
What is class inheritance in python?
What is python distutils?
What is self and init in python?
What is python good for?
What does len() do?
What is slug in python?
What is the use of the break statement?
What’s your preferred text editor?