Friday 15 August 2014

Exercise 13 the hard way python 3 -



Exercise 13 the hard way python 3 -

i'm working on exercise 13 python hard way. i'm trying larn python 3 i'm trying convert code i've learned @ codecademy. thought made typing error copied code in ide. i'm getting error. can guys please explain why happening me. i've done hand total of searches , couldn't find 1 getting error. give thanks guys helping. it's same except () needs run.

script, first, second, 3rd = argv

valueerror: need more 1 value unpack

sys import argv script, first, second, 3rd = argv print ("the script called:", (script)) print ("your first variable is:", (first)) print ("your sec variable is:", (second)) print ("your 3rd variable is:", (third))

the error not passing plenty arguments script. means, var argv has name of script , no more. check len(argv)

you should phone call in way:

python myscript.py variable1 variable2 variable3

if calling script ide, have configure pass arguments.

you can print dynamically variables passed script:

print('script called: %s' % argv[0]) var_number, var in enumerate(argv[1:]): print('the var number %s is: %s' % (var_number, var))

by way, brackets around variable names unnecessary

python python-3.x import argv sys

No comments:

Post a Comment