Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

Python problem

  • 29-04-2017 08:57PM
    #1
    Moderators, Computer Games Moderators, Social & Fun Moderators, Paid Member Posts: 81,199 Mod ✭✭✭✭


    Working my way through zed shaws learn python the hard way, Trying too run the following code but its not working at all

    from sys import argv
    
    script, user_name = argv
    prompt = '> '
    
    print "Hi %s, I'm the %s script." % (user_name, script)
    print "I'd like to ask youa few questions."
    print "Do you like me %s?" % user_name
    likes = raw_input(prompt)
    
    print "Where do live %s?" % user_name
    lives = raw_input(prompt)
    
    print "What kind of computer do you have?"
    computer = raw_input(prompt)
    
    print"""
    Alright, so you said %r about liking me.
    You live in %r. Not sure that is.
    And you have a %r computer. Nice
    """ % (likes, lives, computer)
    


    I keep getting the following error message in power shell

    value error need more than 1 value too unpack


    Any help appreciated.


Comments

  • Registered Users, Registered Users 2 Posts: 291 ✭✭Seridisand


    Working my way through zed shaws learn python the hard way, Trying too run the following code but its not working at all

    from sys import argv
    
    script, user_name = argv
    prompt = '> '
    
    print "Hi %s, I'm the %s script." % (user_name, script)
    print "I'd like to ask youa few questions."
    print "Do you like me %s?" % user_name
    likes = raw_input(prompt)
    
    print "Where do live %s?" % user_name
    lives = raw_input(prompt)
    
    print "What kind of computer do you have?"
    computer = raw_input(prompt)
    
    print"""
    Alright, so you said %r about liking me.
    You live in %r. Not sure that is.
    And you have a %r computer. Nice
    """ % (likes, lives, computer)
    
    I keep getting the following error message in power shell

    value error need more than 1 value too unpack


    Any help appreciated.

    change
    script, user_name = argv
    script = user_name = argv


  • Registered Users, Registered Users 2 Posts: 7,157 ✭✭✭srsly78


    Or launch program with more args. Looks like it was supposed to be launched with 2.


  • Registered Users, Registered Users 2 Posts: 2,062 ✭✭✭Colonel Panic


    import sys
    
    print 'Argument List:', str(sys.argv)
    
    python args.py here are some command line args
    Argument List: ['args.py', 'here', 'are', 'some', 'command', 'line', 'args']
    

    Arg zero is the name of the script. Show us what your command line is


Advertisement