Jump to content
  • Advertisement
Sign in to follow this  
avgprogramingjoe

simple noob typing prob

This topic is 4023 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

----solved please see edit---- k guys I am learning python and have gotten the activepython installed, but I'm having a little problem with the shell log/input thing, the ">>>" I have tryed to write a simple loop, to get down sytax, but keep geting the ">>>" when I want to go to the next line. EX: a=0 while a<10 # when I press enter to go to next line it trys to excute a= a + 1 print a How can I fix this? Thanks, Joe P.S. should I just write it on notepad first? EDIT I figured it all out, just the tut doesn't show how to end a while statement and continue the program. can someone please tell me how. Thanks and sorry for the inconvenience, Joe [Edited by - avgprogramingjoe on June 14, 2007 10:01:28 PM]

Share this post


Link to post
Share on other sites
Advertisement
Yes thanks for your reply though. But how do I end a while statement.
EX
a=1
while a<10:
a= a + 1
### I don't want this to be part of the while statement.
print a

Thanks again,

Joe

Share this post


Link to post
Share on other sites
After you type a = a + 1 and hit enter you'll get another ... prompt. To end the indent block just press enter without typing anything. It will execute the while loop and then return to the >>> prompt.

Edit: Keep in mind that the interactive shell executes each line or block of code immediately after you enter it. You typically use it for learning and testing purposes but you don't actually write lengthy programs in it.

Share this post


Link to post
Share on other sites
Python uses indentation to mark out the blocks. If you start a block, Python will wait until you input a blank line, and then interpret everything up to that point as the block. Of course, everything under the first line will need to be indented at least one level, in order to be part of the block.

So it goes something like (with the text '<tab>' replaced with actual tabs, of course)


>>> for x in range(3):
...<tab>print "hi mom"
...<tab>print x * 2
...
>>> hi mom
0
hi mom
2
hi mom
4

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!