See the Security and Bug Fixes Section - Grub EFI Install Updates Fix Sticky


Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Stuck again, what's wrong?
#1
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.
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)
I keep getting the following error
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:~$
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. 
Old and getting even older lol
Reply


Messages In This Thread
Stuck again, what's wrong? - by colin - 07-13-2018, 09:50 AM
Re: Stuck again, what's wrong? - by bitsnpcs - 09-24-2018, 09:08 PM
Re: Stuck again, what's wrong? - by Shanti - 09-25-2018, 06:23 PM
Re: Stuck again, what's wrong? - by bitsnpcs - 09-25-2018, 06:31 PM
Re: Stuck again, what's wrong? - by Shanti - 09-27-2018, 04:51 PM
Re: Stuck again, what's wrong? - by bitsnpcs - 09-27-2018, 07:58 PM
Re: Stuck again, what's wrong? - by colin - 10-26-2018, 02:17 PM
Re: Stuck again, what's wrong? - by bitsnpcs - 10-26-2018, 08:48 PM

Forum Jump:


Users browsing this thread: 1 Guest(s)