#!usr/bin/env python3
import re

#find the occurence of nobody, print out the position and which lines

nobody_file = open("Python_06_nobody.txt","r")
text = nobody_file.read()

if re.search(r"Nobody",text):
	print("Is there 'Nobody in the text'?")

found = re.findall(r"Nobody",text)
print("Yes! I found", len(found), "'Nobody' in the text")

for found in re.finditer(r"Nobody)",text):
  whole    = found.group(0)
  up       = found.group(1)
  down     = found.group(2)
  up_start = found.start(1) + 1   # need to convert from 0 to 1 notation 
  up_end   = found.end(1)   + 1
  dn_start = found.start(2) + 1
  dn_end   = found.end(2)   + 1

  output = [ whole , up , str(up_start), str(up_end) , down , str(dn_start) , str(dn_end)  ]

  print( "\t".join(output) )
