How to move the turtle where I want to go
<p>So I'm trying to complete this question on my programming course, and it involves drawing stuff with the turtle.
Basically, I'm trying to draw a city skyline, so the program needs to read multiple inputs from the user on one line (the heights of the buildings). I can get it to draw a building, but it only uses the last y-value.</p>

<pre><code>from turtle import *
h = input("Heights: ")
y = h.split()
nxc = -200

#Code for the background

fillcolor("darkslategray")
for i in y:
  for i in y:
    nyc = i
  pencolor("black")
  pendown()
  begin_fill()
  goto(nxc, nyc)
  right(90)
  forward(20)
  right(90)
  forward(nyc)
  right(90)
  forward(20)
  right(90)
  forward(nyc)
  end_fill()
  nxc = nxc + 20
</code></pre>

<p>Help please!</p>

<p>Here's a picture:
<a href="http://i.stack.imgur.com/OsWbA.png" rel="nofollow">Description of the question</a>
<a href="http://i.stack.imgur.com/suQ7M.png" rel="nofollow">Some of the specifics</a></p>

<p>Take out your second <code>for</code> loop:</p>

<pre><code>from turtle import *
h = input("Heights: ")
y = h.split()
nxc = -200

#Code for the background

fillcolor("darkslategray")
for i in y:
  nyc = i
  pencolor("black")
  pendown()
  begin_fill()
  goto(nxc, nyc)
  right(90)
  forward(20)
  right(90)
  forward(nyc)
  right(90)
  forward(20)
  right(90)
  forward(nyc)
  end_fill()
  nxc = nxc + 20
</code></pre>

<p>This second loop will always reach the end, updating <code>nyc</code> each time, before it exits. Thus, for every iteration, <code>nyc</code> will advance to the final value before Python gets to your drawing code.</p>

python turtle-graphics