LPTHW 3 Ex13 understanding issue

i can’t understand ex13. I’m not sure if i missed anything till ex12. Can you explain what exactly going on

Hello and welcome to the forum @loky

This exercice show a way to get values for the variables from “outside” the program.
One provide them when starting the program.

from sys import argv
scriptname, my_name = argv

print("this is my script", scriptname)
print("this is my user name", my_name )

If you now run this code with your user name added like this:

python ex13.py loky

you will get:

this is my script: ex13
this is my user name: loky

If you add variables to argv (script_name, first, second, … ) one also has to add values when running the program (python ex13.py first, second, …)

Hope this help you a little.


So, @ulfen69 already provided some help, but you have to explain what your difficulty is before anyone can help you. Please take the time to explain:

  1. What you did.
  2. What happened.
  3. What you expected to happen.
  4. Why you think this happened instead of what you expected.

You can also simply explain what you don’t understand, such as words and other things.