Hi all,
I'm a Python rookie (doing an online Python for Beginners course via edX) and I'm struggling with the following.
When I want to execute the below-stated lines of code:
Thanks in advance!!
I'm a Python rookie (doing an online Python for Beginners course via edX) and I'm struggling with the following.
When I want to execute the below-stated lines of code:
fhand = open("mbox-short.txt") for line in fhand: line = line.rstrip() if line.startswith("From: "): print(line), it prints the following:
Vincents-MacBook-Air-4:PYTHON DATA STRUCTURES vincentolivers$ /usr/bin/python Python 2.7.10 (default, Aug 17 2018, 19:45:58) [GCC 4.2.1 Compatible Apple LLVM 10.0.0 (clang-1000.0.42)] on darwin Type "help", "copyright", "credits" or "license" for more information. >>> fhand = open("mbox-short.txt") >>> >>> for line in fhand: ... line = line.rstrip() ... if line.startswith("From: "): ... print(line) ...Any ideas on how to print my desired output instead of "...", i.e. all lines that start with "From: " in the handled text file?
Thanks in advance!!