height = input("Enter the height: ") height = int(height) width = input("Enter the width: ") width = int(width) import turtle width = width - 1 turtle.speed(1) turtle.penup() for y in range(height // 2): for x in range(width): turtle.dot() turtle.forward(20) turtle.dot() turtle.right(90) turtle.forward(20) turtle.right(90) for x in range(width): turtle.dot() turtle.forward(20) turtle.dot() turtle.left(90) turtle.forward(20) turtle.left(90) turtle.exitonclick()
I want to print dots in python graphical turtle. For my width, it’s giving out as my input. But for the height, if the number is even I am getting the accurate output but if the number is odd I am getting height - 1. I know that my codes, logics are not efficient & accurate. I am a self-learner (by books only) so kindly help me to figure out what is the problem in my codes.
Thanks in advance