Answers for "indentation error python"

8

python indentationerror

# usually use 4 spaces to indent (don't mix with TABs or IndentationError)
j = 1
site = 'cg'
while(j<= 1):
    if site == 'cg': 
        print('okay') 
    else: 
        print('retry') 
    j += 1
    print ('j: ' + str(j))
print('Done') 					# okay          j: 2        Done
Posted by: Guest on May-13-2021
0

indentation error python

from flask import flask
from redis import Redis, RedisError
import os
import socket

redis = Redis(host="redis", db=0, socket_connnect_timeout=2, socket_timeout=2)

app=Flask(__name__)
@app.route("/")
def hello():

try:
    visits = redis.incr("counter")
except RedisError:
    visits="<i>Cannot connect to Redis, counter disabled</i>"

html="<h3> Hello {name}!</h3>"\
    "<b>Hostname:</b> {hostname}<br/>"
    "<b>Visits:</b> {visits}"
returnhtml.format(name=os.getenv("NAME", "world"), hostname=socket.gethostname(), visits=visits)

if __name__ =="__main__":
    app.run(host='0.0.0.0', port=80)
Posted by: Guest on April-24-2021
0

indentation error

You've missed tabs or spaces
Posted by: Guest on July-18-2020

Browse Popular Code Answers by Language