Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help with identation
#4
(Sep-30-2017, 05:20 AM)pythonbabe Wrote: No Luck even after i changed as above.
You should not get TabError with that code.
Test:
tofind = '<map>'
tofind1 = '</map>'

with open('in.txt') as my_file:
    for num, line in enumerate(my_file, 1):
        if tofind in line:
            print(f'{tofind} at line: {num}')
        if tofind1 in line:
            print(f'{tofind1} at line: {num}')
Output:
<map> at line: 1 </map> at line: 5 <map> at line: 11 </map> at line: 16
Reply


Messages In This Thread
Help with identation - by pythonbabe - Sep-30-2017, 03:47 AM
RE: Help with identation - by metulburr - Sep-30-2017, 04:07 AM
RE: Help with identation - by pythonbabe - Sep-30-2017, 05:20 AM
RE: Help with identation - by snippsat - Sep-30-2017, 09:20 AM
RE: Help with identation - by Larz60+ - Sep-30-2017, 10:11 AM

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020