'File Reader 1O Reading Text Fail
I am trying to read a movie script file ('sw_episode_iv.text') and count how many lines contain "THREEPIO" how can I improve my code below, it just prints zero
with open('sw_episode_iv.txt') as f:
count = 0
read_data = f.read()
for line in read_data:
if "THREEPIO" in line:
count += 1
print(count)
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
