Prompting and Passing

Started by
9 comments, last by Dave Hunt 9 years, 8 months ago
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 :)
Advertisement

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

My Gamedev Journal: 2D Game Making, the Easy Way

---(Old Blog, still has good info): 2dGameMaking
-----
"No one ever posts on that message board; it's too crowded." - Yoga Berra (sorta)

ty :)

but :(

V0OIpNpB.png

How are you invoking the script?

devstropo.blogspot.com - Random stuff about my gamedev hobby

i don't know what do u mean ! :(

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].

devstropo.blogspot.com - Random stuff about my gamedev hobby

like that ?

V1tqkl23.png

ty for helping me :)

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

"We should have a great fewer disputes in the world if words were taken for what they are, the signs of our ideas only, and not for things themselves." - John Locke

Ty all smile.png

V1TUD2lX.png

pls why he use %r & %s

why don't use %r only ?!

This topic is closed to new replies.

Advertisement