Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

Python problem

Options
  • 29-04-2017 8:57pm
    #1
    Moderators, Computer Games Moderators, Social & Fun Moderators Posts: 80,164 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 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 Posts: 7,157 ✭✭✭srsly78


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


  • Registered Users Posts: 2,022 ✭✭✭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