Sign in to follow this  

Prompting and Passing

This topic is 1251 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

i was learning from learnpythonthehardway.org
 
Exercise 14: Prompting and Passing
 
when i do like the exercise 
 
first:
VbjyAvFd.png
 
so i did that :
V0JOC5hI.png
 
 
What should i do !? sad.png
and if can put screen pls put :)
Edited by koka282

Share this post


Link to post
Share on other sites

It should be:

script, user = argv[0], argv[1]

 

argv is a list, and argv[0] is the name of the script, while argv[1] (and [2], [3], etc.) are the parameters given to the script

Share this post


Link to post
Share on other sites

You should call the script through a terminal somewhat like this:

python "new 1.txt" your_name_here

 

Also, it might be easier if the name of the script doesn't contain any spaces, something like new_1.txt, then you could call it without the quotes:

python new_1.txt your_name_here

 

In both cases, the your_name_here argument will be in the argv[1].

Share this post


Link to post
Share on other sites

Your first line to invoke the script from the terminal window was almost correct.  You were just in the wrong directory (hence the error that python gave you "No such file or directory"; it couldn't find "new 1.txt" from its current location).  It looks like your file "new 1.txt" is in the folder C:\Users\ahmed\Desktop\, so you'll need to navigate to that directory before you run python.  This can be done with the cd command (short for change directory):

 

PS C:\User\ahmed> cd Desktop

PS C:\User\ahmed\Desktop> python "new 1.txt" koka282

Share this post


Link to post
Share on other sites

This topic is 1251 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this