[Solved] How to fix indentation errors? [closed]


This should fix indentation to be inline with your code. Check this page out for python indentation best practices.

def Barchart(id, title, data):

    bar_chart = pygal.Bar()
    bar_chart.title = title

    data_cols = data.split(':')
    for x in range(0, len(data_cols)):
        data_num = []
        data_cols_split = data_cols[x].split(',')

        for y in range(1, len(data_cols_split)):
            print(data_cols_split[y])
            data_num.append(int(data_cols_split[y]))

        bar_chart.add(str(data_cols_split[0]), data_num)

    bar_chart.render_to_png('barchart.png')


    s3 = session.resource('s3')
    data = open('barchart.png', 'rb')
    amazonname = str(id) + '.png'
    s3.Bucket(bucket).put_object(Key=amazonname, Body=data)
    data.close()
    with open("barchart.png", "rb") as imageFile:
        imgstring = base64.b64encode(imageFile.read())



    return (imgstring)

0

solved How to fix indentation errors? [closed]