Python Forum
C'mon Indentation !!! - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: Homework (https://python-forum.io/forum-9.html)
+--- Thread: C'mon Indentation !!! (/thread-7740.html)



C'mon Indentation !!! - iseedeadpeople - Jan-23-2018

Obviously, I am new to python. I am getting indentation and space error, Doh Doh Doh Doh Doh

def plot_images(numImages, images, cls_true, cls_pred=None):
	
    assert len(images) == len(cls_true) == numImages
    
    # Create figure with 3x3 sub-plots.
    #fig, axes = plt.subplots(3, 3)
    remainder = numImages % 5
    
    if remainder == 0:
		row = numImages / 5
		
	else:
		row = remainder
    
    fig, axes = plt.subplots(row, 5)
    fig.subplots_adjust(hspace=0.3, wspace=0.3)

    for i, ax in enumerate(axes.flat):
        # Plot image.
        ax.imshow(images[i].reshape(img_shape), cmap='binary')

        # Show true and predicted classes.
        if cls_pred is None:
            xlabel = "True: {0}".format(cls_true[i])
        else:
            xlabel = "True: {0}, Pred: {1}".format(cls_true[i], cls_pred[i])

        ax.set_xlabel(xlabel)
        
        # Remove ticks from the plot.
        ax.set_xticks([])
        ax.set_yticks([])
        
    # Ensure the plot is shown correctly with multiple plots
    # in a single Notebook cell.
    plt.show()
Please help. thanks


RE: C'mon Indentation !!! - buran - Jan-23-2018

Post full traceback in error tags.


RE: C'mon Indentation !!! - Gribouillis - Jan-23-2018

It may be an editor issue. What is your python editor? Did you copy and paste from one source to another?


RE: C'mon Indentation !!! - buran - Jan-23-2018

I guess OP mix tab and 4 spaces for indent and that is why I ask for the traceback. And to teach them to always post the full traceback