Because break cannot be used to break out of an if – it can only break out of loops. That’s the way Python (and most other languages) are specified to behave.
What are you trying to do? Perhaps you should use sys.exit()
or return
instead?
More Related Contents:
- Remove string in python dictionary value
- How to prompt for user input and read command-line arguments [closed]
- How to compare two dates?
- How to connect to Tor browser using Python
- What is the simplest way to SSH using Python?
- How to unzip a list of tuples into individual lists? [duplicate]
- How to stop flask application without using ctrl-c
- How can I initialize a dictionary of distinct empty lists in Python?
- Selenium not able to click on Get Data button on using Python
- Most efficient way to forward-fill NaN values in numpy array
- Retrieve top n in each group of a DataFrame in pyspark
- How to re import an updated package while in Python Interpreter? [duplicate]
- Getting file size in Python? [duplicate]
- Difference between python3 and python3m executables
- json.loads allows duplicate keys in a dictionary, overwriting the first value
- Python/Selenium incognito/private mode
- Efficiently create sparse pivot tables in pandas?
- Pass existing Webdriver object to custom Python library for Robot Framework
- Convert RGB to black OR white
- How to remove or hide x-axis labels from a seaborn / matplotlib plot
- Writing List of Strings to Excel CSV File in Python
- ImportError: No module named ‘MySQL’
- python: unicode in Windows terminal, encoding used?
- Django 1.9 deprecation warnings app_label
- Double donut chart in matplotlib
- Why is any (True for … if cond) much faster than any (cond for …)?
- How can I bind arguments to a function in Python?
- Convert Latitude and Longitude to point in 3D space
- What is exactly a file-like object in Python?
- Numpy equivalent of itertools.product [duplicate]