07-13-2018, 09:50 AM
I'm trying to learn Python3 from the book Learn Python 3 the Hard Way and find it hard going especially when the code keeps on displaying an error. Take for instance, exercise 20.
I keep getting the following error
I've come across this error on a previous exercise but sadly misplaced my notes on how to remedy the error. Can someone help me please.
Code:
# ex20: Functions and Files
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_file = open(input_file)
print("First let's print the whole file:\n")
print_all(current_file)
print("Now let's rewind, kind of like a tape.")
rewind(current_file)
print("Let's print three lines:")
current_line = 1 print_a_line(current_line, current_file)
current_line = current_line + 1 print_a_line(current_line, current_file)
current_line = current_line + 1 print_a_line(current_line, current_file)
Code:
colin@my_new_LinuxLite4.0:~$ python3 ~/python_exp/ex20.pyTraceback (most recent call last): File "/home/colin/python_exp/ex20.py", line 7, in <module> script, input_file = argvValueError: not enough vales to unpack (expected 2, got 1)colin@my_new_LinuxLite4.0:~$
Old and getting even older lol