Reputation: 119
I keep receiving this error from my application:
File "", line 67
for o in obj["physical_address"]:
^
TabError: inconsistent use of tabs and spaces in indentation
Here is my code:
@app.route('/location')
def get_testing_location():
"""Return selected state from drop down menu"""
state = request.args['testing-state']
url = f'https://covid-19-testing.github.io/locations/{state.lower()}/complete.json'
res = requests.get(url)
data = res.json()
for obj in data:
if obj["physical_address"]:
for o in obj["physical_address"]:
add=o["address_1"]
state=o["city"]
print(f'{add} {state}')
import pdb
pdb.set_trace()
I have converted my visual studio code editor to use tabs instead of spaces and yet I still receive the same error.
Upvotes: 0
Views: 1610
Reputation: 9511
Add "editor.renderWhitespace": "all"
in Settings.json. There may be spaces and tabs mixed in your code. It's recommended to indent all by spaces.
Convert indentation to 4 spaces:
Save the file to see if the error goes away.
Upvotes: 1