Jump to content

Python Problem


Recommended Posts

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.

Link to comment
Share on other sites

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:

&gt;&gt;&gt; x = 4
&gt;&gt;&gt; while x &gt; 0:
...     print('x' * x)
...     x -= 1{Enter}
&gt;&gt;&gt; int0x80 = 'hax'
&gt;&gt;&gt; print int0x80

The spots with {Enter} are where the Enter key was pressed.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...