You are Here:
Linux Lite 6.6 FINAL Released - Support for 22 Languages Added - See Release Announcement Section



Stuck again, what's wrong?

Author (Read 8850 times)

0 Members and 1 Guest are viewing this topic.

Re: Stuck again, what's wrong?
« Reply #8 on: October 26, 2018, 04:48:30 PM »
 

bitsnpcs

  • Platinum Level Poster
  • **********
  • 3237
    Posts
  • Reputation: 305
    • View Profile
    • Try to Grow

  • Kernel: 4.x
You are Welcome Colin  :)
 

Re: Stuck again, what's wrong?
« Reply #7 on: October 26, 2018, 10:17:10 AM »
 

colin

  • Occasional Poster
  • **
  • 66
    Posts
  • Reputation: 4
  • Linux Lite Member
    • View Profile
Thanks for the help once again bitsnpcs.
Old and getting even older lol
 

Re: Stuck again, what's wrong?
« Reply #6 on: September 27, 2018, 03:58:36 PM »
 

bitsnpcs

  • Platinum Level Poster
  • **********
  • 3237
    Posts
  • Reputation: 305
    • View Profile
    • Try to Grow

  • Kernel: 4.x
You are welcome @Shanti  :) It's looking good.
 

Re: Stuck again, what's wrong?
« Reply #5 on: September 27, 2018, 12:51:59 PM »
 

Shanti

  • New to Forums
  • *
  • 16
    Posts
  • Reputation: 14
  • Linux Lite Member
    • View Profile

  • CPU: Core i5 vPro

  • MEMORY: 16Gb
Gedit up now  :)  thanks for template help.


 

Re: Stuck again, what's wrong?
« Reply #4 on: September 25, 2018, 02:31:03 PM »
 

bitsnpcs

  • Platinum Level Poster
  • **********
  • 3237
    Posts
  • Reputation: 305
    • View Profile
    • Try to Grow

  • Kernel: 4.x
@Shanti great work, glad you liked Python 8)
 

Re: Stuck again, what's wrong?
« Reply #3 on: September 25, 2018, 02:23:38 PM »
 

Shanti

  • New to Forums
  • *
  • 16
    Posts
  • Reputation: 14
  • Linux Lite Member
    • View Profile

  • CPU: Core i5 vPro

  • MEMORY: 16Gb
need to install gedit.






Python looks fun
 

Re: Stuck again, what's wrong?
« Reply #2 on: September 24, 2018, 05:08:56 PM »
 

bitsnpcs

  • Platinum Level Poster
  • **********
  • 3237
    Posts
  • Reputation: 305
    • View Profile
    • Try to Grow

  • Kernel: 4.x
Hello @colin ,
it looks like you are running the file incorrectly as you are not specifying the command in terminal.
I do not have the Python3 book only the Python2, I had a try at this one though to help :) .
The Python, notice the line changes and indentations.



The test.txt file used (contents are his words not mine) from an exercise in the Python2 book, I just renamed it to use for this try.



How to run it in terminal



On highlight in terminal see #1, #2 and #3 above, these are the components of the command that you need.
For #2 you can either cd to the directory containing your Python files, or you can enter in your Path as previously. I just put it in Home directory as its temporary for this post.
#3 is what you have missed in the terminal command ?  or it is in another folder than the Python file is.
« Last Edit: September 24, 2018, 05:22:54 PM by bitsnpcs »
 

Stuck again, what's wrong?
« Reply #1 on: July 13, 2018, 05:50:59 AM »
 

colin

  • Occasional Poster
  • **
  • 66
    Posts
  • Reputation: 4
  • Linux Lite Member
    • View Profile
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: [Select]
# 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: [Select]
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
 

 

-->
X Close Ad

Linux Lite 6.6 FINAL Released - Support for 22 Languages Added - See Release Announcement Section