Why am I getting a syntax error for unexpected indent? The code is supposed to b
ID: 3916695 • Letter: W
Question
Why am I getting a syntax error for unexpected indent? The code is supposed to be outputting a user entered message in fonts and colors based on ordinal values.
import graphics
from graphics import *
win = GraphWin("name", 500, 500)
win.setBackground(color_rgb(255,255,255))
#creating user input box
input_box = Entry(Point(250, 250), 10)
input_box.draw(win)
userentry = input_box.getText()
#this is where the color, fonts should come into play.
for userentry in message:
userentry = Text( Point( x + 1, ord(c) / 2 + 1 ), c)
userentry.setSize( 36 )
userentry.setTextColor( 'black' )
userentry.draw( win )
userentry = Text( Point( x, ord(c) /2 ), c)
userentry.setSize( 36 )
userentry.setTextColor( 'Cyan' )
userentry.draw( win )
x = x + 20?
Explanation / Answer
After the statemeent 'for userentry in message:' there is no indent
the statement should have been
for userentry in message:
userentry = Text( Point( x + 1, ord(c) / 2 + 1 ), c)
userentry.setSize( 36 )
userentry.setTextColor( 'black' )
userentry.draw( win )
userentry = Text( Point( x, ord(c) /2 ), c)
userentry.setSize( 36 )
userentry.setTextColor( 'Cyan' )
userentry.draw( win )
x = x + 20
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.