Hi i was going through regular expression lecture where we have to import mbox-short.txt
import re
hand=open(‘first.txt’)
for line in hand:
line=line.rstrip()
if re.search("^from:",line):
print(line)
this code give runs but shows error
Hi, Shankar.
Can you check the content inside the file ? does the file contains strings starting from “From:” or “from:”.
Kindly share the error screenshots so that I can understand what may be the error.
All the best!
Solved it didn’t knew file has to be in folder where python i kept the file in e drive
Now i have error AttributeError: ‘try1’ object has no attribute ‘letsdo’ and
AttributeError: ‘partied’ object has no attribute ‘tested’ while doing object and constructor part
i have attached the screenshot below
Hi, Shankar.
- Kindly check your code once again in first example why you have written b in the last line.?
- Your indentations are not correct.
- In second example you are calling the function letsdo without passing any arguments but it is expecting one argument.
Kindly check the screenshots for more informations.
All the best!