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.


    Can’t use split(‘\t’) on inputs separated by tabs

    Pythonista
    input split tab
    6
    7
    2444
    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.
    • Simplemathic
      Simplemathic last edited by Simplemathic

      I have to write a program that expects numbers separated by tabs (‘\t’) as its input. I tried to Create an input like this in Pythonista using the tab (upper left button) but that was not recognized as ‘\t’. (The split() function was unable to detect tabs as ‘\t’) How could I create this type of input?

      cvp mikael 2 Replies Last reply Reply Quote 0
      • cvp
        cvp @Simplemathic last edited by

        @Simplemathic for me, running this line of code prints True

        print('a	b' == 'a\tb')
        

        I've typed a tab between a and b

        1 Reply Last reply Reply Quote 0
        • mikael
          mikael @Simplemathic last edited by

          @Simplemathic, you might have some other problem, or I am misunderstanding your issue. This works as expected when given numbers separated by the Pythonista tab key:

          input_str = input('Numbers separated by tabs: ')
          
          for n in input_str.split():
              print(n)
          
          1 Reply Last reply Reply Quote 0
          • Simplemathic
            Simplemathic last edited by

            So my original problem was that splitting an input separated by tabs using split(‘\t’) did not split the string up. However, as mikael pointed it out, using split() - leaving it empty - works! Thank you for the answers!

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

              This post is deleted!
              1 Reply Last reply Reply Quote 0
              • Anderson_Vian
                Anderson_Vian last edited by Anderson_Vian

                This post is deleted!
                1 Reply Last reply Reply Quote 0
                • NelsonPalmer
                  NelsonPalmer last edited by NelsonPalmer

                  This post is deleted!
                  1 Reply Last reply Reply Quote 0
                  • First post
                    Last post
                  Powered by NodeBB Forums | Contributors