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.


    Print function

    Pythonista
    3
    5
    2709
    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.
    • Berg
      Berg last edited by ccc

      Hello,
      I'm totally new to the Python language and to Pythonista as well.
      I got the Pythonista app for my iPad Air and tried a few thing here and there. Maybe it is my lack of reading all the tutorials or maybe I'm missing something.
      It seems the "print" function is not working for me, I mean, not bringing in any results, like it does in a regular computer. As in the example below:

      >>> x = 100
      >>> y =200
      >>>  if:
      >>> x + y == 300:
          print ("300")
      >>> 300
      

      this result does not show, it all stops in the previous line, print.
      Any help would be appreciated.
      Thank you.

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

        Proper syntax is:

        if x + y == 300:
            print(x + y)
        

        Under the wrench icon, I would recommend running Analyze (pyflakes) and Check Style to automatically fix code issues.

        Berg 1 Reply Last reply Reply Quote 0
        • JonB
          JonB last edited by

          Are you doing this in the console, or the editor?

          I'll point out that you have a syntax error -- you want

          if x+y == 300:
              print("300")
          

          not

          if:
             x+y==300:
          

          If you ran this, you will get a syntax error on the if line, and the x+y==300 line.

          If you run this in the editor, you may need to slide your finger left to reveal the console -- if I recall correctly, the console is shown automatically the first time something is displayed, but not subsequently.
          .
          It is also possible that in whatever example you actually ran, maybe your condition was not being satisfied. Try adding

          else:
             print('not 300.  x+y=={}'.format(x+y) )
          

          to help you debug.

          Or, if you just want to test out print:

          print('Hello World!')
          
          1 Reply Last reply Reply Quote 0
          • Berg
            Berg last edited by

            Sorry, I typed that in a hurry, at work; you're right about the syntax error :)
            I'm not sure if I'm using the console or editor, but I'll check that out and try the example you suggested and will reply back. Thanks so much for the reply!

            1 Reply Last reply Reply Quote 0
            • Berg
              Berg @ccc last edited by

              @ccc
              Thanks so much! I'll try your recommendations

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