'x' is an invalid keyword argument for this function
Hire the world's top talent on demand or became one of them at Toptal: https://topt.al/25cXVn
and get $2,000 discount on your first invoice
--------------------------------------------------
Take control of your privacy with Proton's trusted, Swiss-based, secure services.
Choose what you need and safeguard your digital life:
Mail: https://go.getproton.me/SH1CU
VPN: https://go.getproton.me/SH1DI
Password Manager: https://go.getproton.me/SH1DJ
Drive: https://go.getproton.me/SH1CT
Music by Eric Matyas
https://www.soundimage.org
Track title: Ancient Construction
--
Chapters
00:00 'X' Is An Invalid Keyword Argument For This Function
00:49 Accepted Answer Score 11
01:21 Answer 2 Score 0
01:35 Answer 3 Score 4
02:27 Answer 4 Score 0
02:39 Thank you
--
Full question
https://stackoverflow.com/questions/1147...
--
Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...
--
Tags
#python #python27
#avk47
ACCEPTED ANSWER
Score 11
In place of this:
int(x = raw_input('x:\n')) #max number
try this:
x = int(raw_input('x:\n')) #max number
similarly for the other input statements.
Built-in Python function raw_input() "reads a line from input, converts it to a string ". In order for you to use to use the input as an integer, you need to convert the string to int with the help of the int() function which converts "a string or number to a plain integer". From your code it looks like you had the basic idea, but your syntax was a bit tangled up.
ANSWER 2
Score 4
Unlike in C, Python assignment statements can't be used as expressions in arguments.
For example, the following simply isn't legal, and will result in a SyntaxError:
if name = name + 1:
pass
The reason you are receiving a TypeError instead of a SyntaxError in this case is because of Python's keyword argument feature. Python allows you to pass named arguments to functions in the form: foo(arg1=0, second_argument="hello"). Thus the interpreter thinks that this is what you're trying to do.
The error message your receiving is the result of the Python interpreter thinking that you are passing a keyword argument to int(). int(), of course, does not take the keyword argument "x" (or "y" or "z" for that matter), hence the error. This is what you should do instead:
x = int(raw_input("x:\n"))
y = int(raw_input("y:\n"))
z = int(raw_input("z:\n"))
ANSWER 3
Score 0
try this
x,y,z, = int(raw_input("x:")),int(raw_input("y:")),int(raw_input("z:"))
this is the output
>>> x,y,z, = int(raw_input("x:")),int(raw_input("y:")),int(raw_input("z:"))
x:5
y:6
z:7
>>> x
5
>>> y
6
>>> z
7
ANSWER 4
Score 0
If you ever want a shorter version, try this:
x,y,z = (int(raw_input(var+':')) for var in "xyz")
(It works the same as Joran Beasley's version)