-1

I am writing a simple command line contact manager. i want to be able to add a new contact with the following command.
manager.py add -n NAME -p PHONENUMBER
but whenver i add a contact using firstname and lastname, the code throws errors.
eg. manager.py add -n emeka onwuzulike +23464715326.
this is my code
Usage: manager.py add -n NANE -p PHONENUMBER

2 Answers2

0

the problem you are having is because each argument is split on the space character so what is being sent is:

  • add
  • -n
  • emeka
  • onwuzulike
  • +23464715326

you have a few options around this, the easiest I can think of is instead of using a space in a name, use a delimiter like an underscore(_) and then in your script replace the _ with a space.

Or try encapsulating the name in quotes, depending on the command prompt it will sometimes parse as a single arguement. Due to not actually giving us any code, I am unable to test.

Kaden
  • 81
  • 1
  • 9
0

to achieve this, you need to put a string a one the name arguement like so
manager.py add -n 'emeka onwuzulike' -p 08064715300