In which type of loop structures can the break statement be used in Python?
- both for and while loops
- for loop
- neither for nor while loops
- while loop
The 'break' statement can be used in both 'for' and 'while' loops in Python. It is used to exit the loop prematurely based on a certain condition, making it a useful control structure for loop termination.
Loading...
Related Quiz
- What would be the time complexity of inserting an element in a balanced Binary Search Tree?
- Which function in Matplotlib is primarily used to create bar plots?
- In Scikit-learn, ____ is the method used to train a model using the training data.
- To create a tuple with a single item, you need to add a _______ after the item.
- To get a deep copy of nested lists, the copy module provides the _______ method.