What does the Python error 'imput expected at most 1 arguments, got 3' mean?

python error types
python raise
python raise error
syntax error python
runtime error python
python try except: print error
python exception message
python catch all exceptions

I'm new to Python and was creating a text-based adventure game on my PC yesterday, when I encountered this error, which I can't figure it out. Could someone explain it to me?

choice1 = input('''Oh, you. You are finally awake. You have been out cold for the last 10 hours! I am''' ,giant, ''', and I will be your guide in defeating the dark lord Thaldmemau. Well, shall we get to it?
A: Where am I?
B: Ok, we will go!
C: Who are you again?''').lower()

if choice1 == 'a':
     print('You are in a recovery room in the Realm of Power, one of the seven universes of Epta. ')
elif choice1 == 'b':
     print('Ok, let me just give you a brief overview of what we will do and how to fight enemies!')
elif choice1 == 'c':
     print('I am' ,giant, '! I am a giant (but do not worry, I am a friendly giant). I do have some very good abilities, most of which are centred around the magic type of' ,magic, '!')

In this line, you called the input function with three arguments:

choice1 = input('''Oh, you. .... I am''', giant, ''', and ''').lower()

If you want to place the content of the string variable giant into the string the user sees, you can use string concatenation:

input('Oh, you. You are finally awake. You have been out cold '
      'for the last 10 hours! I am ' + giant + ', and I will be '
      'your guide in defeating the dark lord Thaldmemau.'
      '''Well, shall we get to it?
A: Where am I?
B: Ok, we will go!
C: Who are you again?)'''

Or string formatting:

input('''Oh, you. You are finally awake. You have been out cold 
for the last 10 hours! I am {giant}, and I will be your guide in
defeating the dark lord Thaldmemau.  Well, shall we get to it?
A: Where am I?
B: Ok, we will go!
C: Who are you again?)'''.format(giant=giant))

8. Errors and Exceptions — Python 2.7.18 documentation, Syntax errors, also known as parsing errors, are perhaps the most at) the token preceding the arrow: in the example, the error is detected at� The other kind of errors in Python are exceptions. Even if a statement or expression is syntactically correct, it may cause an error when an attempt is made to execute it. Errors detected during execution are called exceptions. Exceptions come in different types, and the type is printed as part of the message.

Here's some code that's basically equivalent to yours:

name = "Tom"
user_input = input("My name is", name, "- what's yours?")

Output:

TypeError: input expected at most 1 arguments, got 3

If I would use print instead, everything would work the way you expect it to:

name = "Tom"
print("My name is", name, "- what's yours?")

Output:

My name is Tom - what's yours?

I'm guessing that's where the confusion comes from. print accepts as many arguments as you want - I'm giving it three separate strings - first "My name is", then the variable name (which is also a string), and finally the third string "- what's yours?".

input is different. It accepts either 0 or 1 arguments exactly. If you try to give it more than 1, it will raise a TypeError.

So, you'll want to use string formatting to solve this particular problem. The idea is that you will generate a single string and pass that as an argument to the input function:

name = "Tom"
user_input = input(f"My name is {name} - what's yours?")

8. Errors and Exceptions, 8.1 Syntax Errors. Syntax errors, also known as parsing errors, are perhaps the most common kind of complaint you get while you are still learning Python:. Python enforces it with an iron fist. Whenever you have a situation with code inside of a statement (such as the code that defines the main()function), that 'inside' code must be indented, and must be indented consistently. If you forget to indent, you'll see this error.

print lets you provide multiple str arguments, and it will print each of them separated by a space (or whatever string is specified by the sep argument).

input, however, requires a single str argument; it is your responsibility to join multiple strings yourself. For example,

choice1 = input(f'''Oh, you. You are finally awake. You have been out cold for the last 10 hours! I am {giant}, and I will be your guide in defeating the dark lord Thaldmemau. Well, shall we get to it?
A: Where am I?
B: Ok, we will go!
C: Who are you again?''').lower()

Error Types in Python, Python - Error Types. The most common reason of an error in a Python program is when a certain statement is not in accordance with the prescribed usage. Such an error is called a syntax error. The Python interpreter immediately reports it, usually along with the reason. Python Logical Errors (Exceptions) Errors that occur at runtime (after passing the syntax test) are called exceptions or logical errors.

The input function can only take one argument. Your input statement with the commas is set up as the first part of the sentence, 'giant' and the rest of the sentence as 3 arguments. You can use concatenation to fix this, if 'giant' is a string use + to concatenate.

Python Exceptions: An Introduction – Real Python, In Python, an error can be a syntax error or an exception. In this article, you will see what an exception is and how it differs from a syntax error. After that, you will � KeyError in Python is raised when you attempt to access a key that is not in a dictionary. The mapping logic is a data structure that maps one set of data to significant others. Hence, it is an error, which is raised when the mapping is accessed and not found.

Python Errors and Built-in Exceptions, In this tutorial, you will learn about different types of errors and exceptions that are built-in to Python. They are raised whenever the Python interpreter encounters� Python exceptions are errors that are detected during execution and are not unconditionally fatal: you will soon learn in the tutorial how to handle them in Python programs. An exception object is created when a Python script raises an exception.

Python Programming/Errors, Syntax errorsEdit. Syntax errors are the most basic type of error. They arise when the Python parser is unable to understand a line of code. Syntax errors are� Error handling in Python is done through the use of exceptions that are caught in try blocks and handled in except blocks.

Intro Python Debugging, Another type of syntax error will simply say invalid syntax. An invalid syntax error means that there is a line that python doesn't know what to do with. The last� Python is upset because you are attempting to assign a value to something that can't be assigned a value. ((t)/length) * t += string When you use an assignment operator, you assign the value of what is on the right to the variable or element on the left.

Comments
  • input is a function. it takes one argument. when calling input(a, b, c) that's 3 arguments. You may want to either concatenate those strings, or look into string interpolation
  • that's the print function, and it's called with 5 arguments (which is fine)
  • English as a second language is welcome here but a certain minimum level of English proficiency is probably necessary before questions can be helpfully answered. (Keep studying!)