I am trying to run the following code from a coding book I have but I get this error:
Traceback (most recent call last): File "ex20.py", line 3, in script, input_file = argv ValueError: need more than 1 value to unpack
I have created a txt file called input_file and tried other troubleshooting methods but I continue to get errors.
from sys import argv
script, input_file = argv
def print_all(f):
print f.read()
def rewind(f):
f.seek(0)
def print_a_line(line_count, f):
print line_count, f.readline()
current_line = open(input_file)
print "First let's print the whole file:\n"
print_all(current_file)
print("Now lets rewind, kind of like a tape")
current_line = 1
print_a_line(current_line, current_line)
current_line = current_line + 1
print_a_line(current_line, current_file)
I expect it to print and work as coded.