omz:forum

    • Register
    • Login
    • Search
    • Recent
    • Popular

    Welcome!

    This is the community forum for my apps Pythonista and Editorial.

    For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.


    Getting started

    Pythonista
    run program save program
    4
    9
    3441
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • dougler1
      dougler1 last edited by ccc

      I’m new to python and use IDLE on my laptop.
      I copied some code into what appears to be the editing area - where the examples appear.
      I gave it a name that appears on the upper tabs, but I can’t run the program. The run icon above dose nothing and I can’t find documentation on the mechanics of the editor.

      1 Reply Last reply Reply Quote 0
      • stephen
        stephen last edited by

        ensure your script file has .py extention if run is grayed out. Also what is expected when you run the script?

        1 Reply Last reply Reply Quote 0
        • dougler1
          dougler1 last edited by

          The script is called gameBoard.py which is in gray text in the tabs. The run arrowhead is in gray. From the examples I think it should be in green to be active.
          The file itself is just a series of print statements about 10 lines long. I just want to get a feel for the editor

          mikael stephen 2 Replies Last reply Reply Quote 0
          • mikael
            mikael @dougler1 last edited by mikael

            @dougler1, my ”run triangle” or ”play button” is just empty (white) with a blue outline. Could be different with a different theme, though.

            I assume nothing happens when you press it? Or could it very briefly turn into a box with an x in it?

            Maybe paste your code in here just to be sure?

            1 Reply Last reply Reply Quote 0
            • 7upser
              7upser last edited by 7upser

              @dougler1, or send a screenshot, so we know where you are within your Pythonista.

              To send a screenshot you can use:
              ![tag](url)
              -and-
              https://imgur.com/

              1 Reply Last reply Reply Quote 1
              • stephen
                stephen @dougler1 last edited by

                @dougler1

                as @mikael said, if you could present the code it would help alot.if itsbonly 10 or so lines then you could be executing the code but not telling it to show anything. thisvwould make it seem like its doing nothing when in fact it just ran the program really fast

                1 Reply Last reply Reply Quote 0
                • dougler1
                  dougler1 last edited by ccc

                  Here Is the code I’m trying to run

                  board=['1','2','3', '4','5', '6', '7','8','9']
                  def play():
                  	print('got here')
                  	printBoard
                  def printBoard(): 
                  	print
                  	for square in range (0,9 ):
                  		print('|', board [square],'|', end='')
                  		
                  		if square ==2 or square ==5 :
                  			print ('\n')
                  			print('__________')
                  			print
                  			
                  if __name__==' __main__':
                  		play()
                  
                  stephen 1 Reply Last reply Reply Quote 0
                  • dougler1
                    dougler1 last edited by

                    Error was between seat and keyboard...thanks

                    1 Reply Last reply Reply Quote 0
                    • stephen
                      stephen @dougler1 last edited by

                      Just a seggestion 😊 ... or two if board is going to be a list of numeric strings in order you can also just use range to create your board squars without the list object. that way you dont create two sparate lists each time (board and range). and fstring to help control spacing more. while we are t it lets throw in a new line variable 😁

                      For Example:

                      for square in range(1, 10): # 1-9
                      	nl = '\n' if square%3 == 0 else ''
                      	print(f'| {square} |{nl}', end='')
                      

                      prints:

                      | 1 || 2 || 3 |
                      | 4 || 5 || 6 |
                      | 7 || 8 || 9 |
                      

                      As for myself, I like to use Unicode in my console apps
                      I'll show an example of how I would implement a Board 😊

                      using the same 3x3 setup:

                      top = "╔═╦═╦═╦═╦═╦═╗\n"
                      between = "╠═╬═╬═╬═╬═╬═╣\n"
                      bottom = "╚═╩═╩═╩═╩═╩═╝\n"
                      board = top
                      rows = 3
                      for n in range(rows):
                      	board += f'╠ {n*3+1} ╬ {n*3+2} ╬ {n*3+3} ╣\n'
                      	if n+1 != rows:
                      		board += between
                      	else:
                      		board += bottom
                      
                      print(board)
                      

                      prints:

                      ╔═╦═╦═╦═╦═╦═╗
                      ╠ 1 ╬ 2 ╬ 3 ╣
                      ╠═╬═╬═╬═╬═╬═╣
                      ╠ 4 ╬ 5 ╬ 6 ╣
                      ╠═╬═╬═╬═╬═╬═╣
                      ╠ 7 ╬ 8 ╬ 9 ╣
                      ╚═╩═╩═╩═╩═╩═╝
                      

                      many ways to do it. just figured id share 😇

                      1 Reply Last reply Reply Quote 0
                      • First post
                        Last post
                      Powered by NodeBB Forums | Contributors