This code shows a fundamental misunderstanding of how input()
works in Python 3.
First, the input()
function in Python 3 is equivalent to raw_input()
in Python 2. Your error shows that you are using Python 2.
So let's read the error message you got:
We know what line the error is on:
File "mailerproj.py", line 139, in <module>
And it shows us the line:
["1"], "Flag this message/s as high priority? [yes|no]")
And then it explains the issue:
TypeError: [raw_]input expected at most 1 arguments, got 2
This means you've given input()
the wrong arguments - you've given it two ["1"]
and "Flag this message/s as high priority? [yes|no]"
and it expects one.
Here is the python help on raw_input
:
Help on built-in function raw_input in module builtin:
raw_input(...)
raw_input([prompt]) -> string
Read a string from standard input. The trailing newline is stripped. If the
user hits EOF (Unix: Ctl-D, Windows: Ctl-Z+Return), raise EOFError. On Unix,
GNU readline is used if enabled. The prompt string, if given, is printed
without a trailing newline before reading.
So you need to give it one argument as input. This can be a string (e.g. "Hello"
) an integer (e.g. 125
), a float (e.g. 3.14
), a list, a tuple, a boolean and others. It returns a string into the variable.
You need your code to look more like this:
highpri = raw_input("[1] Flag this message as high priority? [yes|no] > ")
highpri = highpri.upper() # Make the input uppercase for the if
if highpri != 'YES': # If it is not yes, remove the flags.
prioflag1 = ''
prioflag2 = ''
else: # If the input is yes, set the flags.
prioflag1 = '1 (Highest)'
prioflag2 = 'High'