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
knip
 
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'))

Output
Code: Select all
Hello   This   Is   Knipset
3
New Users, Read This
Join the #python-forum IRC channel on irc.freenode.net!
Image
User avatar
Yoriz
 
Posts: 1052
Joined: Fri Feb 08, 2013 1:35 am
Location: UK


Return to General Coding Help

Who is online

Users browsing this forum: Google [Bot], W3C [Linkcheck] and 2 guests