Sep-30-2017, 03:47 AM
Following python program is giving indentation error. Please have a look at the for loop section and suggest me what i am doing wrong.
Python Version : 3.5
Some of the lines has white spaces in front of the content. I don't know how to paste the content as is.
I used the quote section here. But no help.
Python Version : 3.5
#/usr/bin/env python file='/home/map' F=open(file) file_content=F.readlines() length=len(file_content) print('No of lines in input file is :', length) tofind='<map>' tofind1='</map>' with open(file) as myFile: for num, line in enumerate(myFile, 1): if tofind in line: print ('found at line: ', num) if tofind1 in line: print('found at line: ', num)Error is:
Error: File "linenumber.py", line 27
if tofind1 in line:
^
TabError: inconsistent use of tabs and spaces in indentation
Input File content is:Some of the lines has white spaces in front of the content. I don't know how to paste the content as is.
I used the quote section here. But no help.
Quote:<map>
/apps/information
/apps/information/one
/apps/education
</map>
king
queen
god
parents
<map>
/dir
/tmp
/
/var/tmp
</map>