Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

By using from graphics import* (you can find the import program here: http://mcs

ID: 3552017 • Letter: B

Question

By using from graphics import* (you can find the import program here: http://mcsp.wartburg.edu/zelle/python/graphics.py. just copy and paste it into a text editor and save it where python can see)

So far I have this:

from graphics import *

text = raw_input("Type some words, then hit enter. ")

win = GraphWin("words",400,600)

for i in range(len(text)+1):

message = Text(Point(10,10), text)


message.draw(win)

win.getMouse()

win.close()


where I have the window and everything. Let's say the input is: Red fox

I was wondering how I can make it so that it prints out:

R

Re

Red

Red

Red f

Red fo

Red fox



Explanation / Answer

Since the Point value is showing the center of the text so the texts will not be aligned.


text = raw_input("Type some words, then hit enter. ")

win = GraphWin("words",400,600)

for i in range(len(text)):
    message = Text(Point(40,20*(i+1)), text[:i+1])
    message.draw(win)
win.getMouse()
win.close()