Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/python
- def extract_third_lines():
- try:
- filename = raw_input("Enter name of file to read: ")
- with open(filename) as f:
- lines = f.readlines()
- my_str = ""
- for line in lines[2::3]:
- my_str += line
- return my_str # extracts string made from every 3rd line
- except IOError:
- return "Error: can't find file or read data."
- else:
- f.close()
- def main():
- print extract_third_lines()
- main()
Advertisement
Add Comment
Please, Sign In to add comment