Reputation: 1
for count, word in vk_list:
bwidth = 600 / (len(vk_list) * 2 + 1)
bheight = vk_list[index][0] / 6
turtle.begin_fill()
turtle.left(20)
turtle.right(40)
turtle.write(count)
turtle.right(90)
turtle.forward(40)
turtle.right(90)
turtle.forward(bheight)
turtle.backward(40)
turtle.end_fill()
Code is meant to draw histogram, but as I attached, this code gives me slanted lines, but I just can't understand it. How can I fix this?
Upvotes: 0
Views: 653
Reputation: 742
turtle.left
and turtle.right
turn the turtle by the angle specified in the parenthesis
so turtle.left(20)
changes the angle of the turtle by 20 degrees
hence the slanted lines
turtle.forward
actually moves the turtle ahead
read the docs here
here's how you draw a 100*200 rectangle with a turtle
import turtle
t = turtle.Turtle()
t.forward(100)
t.left(90)
t.forward(200)
t.left(90)
t.forward(100)
t.left(90)
t.forward(200)
Upvotes: 1