Forum Archive

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

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

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

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

I've typed a tab between a and b

mikael

@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)
Simplemathic

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!

GxAl2aa

```

bolded text```

Anderson_Vian

I was looking for the same info, tried doing the same but it didn't worked!

NelsonPalmer

Effective and interesting post for reading WalgreensListens