简体   繁体   中英

I don't understand what this error means

I am brand new to programming. I have researched this error message and I am not sure what it means or how to solve the problem; does anyone have any insight for this error.

    firstName=input('Enter your first name: ')
    middleName=input('Enter your middle name: ')
    lastName=input(firstName,middleName'enter your last name: ')

    >>> 
    Enter your first name: Steve
    Enter your middle name: Smith
    >>>Error
    Traceback (most recent call last):
    File "C:\Users\Steve\Desktop\rps.py", line 3, in <module>
    lastName=input(firstName,middleName,'Enter your last name: ')
    TypeError: input expected at most 1 arguments, got 3
    >>>
lastName=input(firstName,middleName'enter your last name: ')

The error refers to the line above. It says that 'input', the function, expects a single argument, but you've given three. I expect your last line should probably be:

lastName=input('Enter your last name: ')

I do not mean to insult your intelligence or anything. But if you're brand new to programming, I would really consider a course, book, and/or inspecting existing code examples like 'hello world' and so on carefully.

Due to the fact you did not post your actual code of 'rps.py', we can't know exactly what's going wrong.

But I'm quite sure that you have a function called 'input', which accepts a string. As 'last name', you try to call the 'input' method with 3 arguments. the 'firsname', 'middlename', and the 'enter your lastname' attribute.

To create a string parameter from string variables and a string literal, you would concatenate them to one string, which then is a correct parameter for the input(str) function. See also https://docs.python.org/3/library/string.html .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM