Help In Counting Tabs in a file

This is the place for queries that don't fit in any of the other categories.

Help In Counting Tabs in a file

Postby knip » Thu Jan 16, 2014 9:01 pm

Hi All,
i need to count number of tabs in a text file.
for instance if my test file has below text it should result output as 3
Code: Select all
Hello    This    Is    Knipset

can anyone help me in this
Posts: 3
Joined: Thu Jan 16, 2014 8:23 pm

Re: Help In Counting Tabs in a file

Postby Yoriz » Thu Jan 16, 2014 9:05 pm

Code: Select all
text = 'Hello\tThis\tIs\tKnipset'
print text
print text.count('\t'))

Code: Select all
Hello   This   Is   Knipset
Due to the reasons discussed here we will be moving to on October 1 2016
This forum will be locked down and no one will be able to post/edit/create threads, etc. here from thereafter. Please create an account at the new site to continue discussion.
User avatar
Posts: 1672
Joined: Fri Feb 08, 2013 1:35 am
Location: UK

Return to General Coding Help

Who is online

Users browsing this forum: No registered users and 9 guests