bobbyb1980 Posted January 31, 2012 Share Posted January 31, 2012 Hey guys. I'm having a problem in Python, I know it's something stupid but I can't seem to google my way out of this one. When I type code into the interpreter, for example this is the effect I WANT: >>> x = 4 >>> while x > 0: print('spam!' * x) x -= 1 However, this is what actually happens: >>> while x > 0: ... print('spam!' * x) File "<stdin>", line 2 print('spam!' * x) ^ IndentationError: expected an indented block Would anyone tell me how I can successfully indent? Thanks a lot guys. Long live hak5. Quote Link to comment Share on other sites More sharing options...
int0x80 Posted January 31, 2012 Share Posted January 31, 2012 Tab Quote Link to comment Share on other sites More sharing options...
bobbyb1980 Posted January 31, 2012 Author Share Posted January 31, 2012 Lol. My book said enter twice. Thanks. Quote Link to comment Share on other sites More sharing options...
Mr-Protocol Posted January 31, 2012 Share Posted January 31, 2012 Tab Best single word answer lol. Python uses indentation instead of brackets or braces in other languages. Quote Link to comment Share on other sites More sharing options...
int0x80 Posted January 31, 2012 Share Posted January 31, 2012 Lol. My book said enter twice. Thanks. Possibly a mis-read as you will need to hit enter twice to create more code not in the indented block. Example: >>> x = 4 >>> while x > 0: ... print('x' * x) ... x -= 1{Enter} ...{Enter} xxxx xxx xx x >>> int0x80 = 'hax' >>> print int0x80 hax The spots with {Enter} are where the Enter key was pressed. Quote Link to comment Share on other sites More sharing options...
bobbyb1980 Posted February 1, 2012 Author Share Posted February 1, 2012 Thanks a lot for the good practical help intox. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.