You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

调试代码时出现TypeError: input expected at most 1 arguments, got 3错误,如何修复?

Fixing "TypeError: input expected at most 1 arguments, got 3" in Python

Hey fellow developer! Let's get this error sorted out quickly.

Why this error happens

Python's built-in input() function only accepts one argument (the optional prompt string that shows up to the user). When you pass 3 separate arguments to it, Python throws this TypeError because it doesn't know how to handle multiple inputs here.

Common problematic code example

Chances are your code looks something like this:

user_input = input("Enter your", " full", " name:")

This tries to pass 3 distinct string arguments to input()—which is exactly what's triggering the error.

How to fix it

Here are 3 straightforward ways to resolve this:

  • Concatenate the strings into one
    Use the + operator to combine your prompt parts into a single string before passing it to input():

    user_input = input("Enter your" + " full" + " name:")
    # Or even better, just write it as one string directly:
    user_input = input("Enter your full name:")
    
  • Use string formatting
    If you're working with variables in your prompt, use f-strings (Python 3.6+) or .format() to build a single prompt string:

    # Using f-strings
    title = "full"
    user_input = input(f"Enter your {title} name:")
    
    # Using .format()
    user_input = input("Enter your {} name:".format("full"))
    
  • Double-check you're using the right function
    It's easy to mix up input() with print()—since print() does accept multiple arguments. If you accidentally used input() when you meant to print something first, split the logic:

    # Wrong: Trying to print multiple parts with input()
    # input("Hello", "there", "user!")
    
    # Right: Print first, then get input
    print("Hello", "there", "user!")
    user_input = input("Enter your name:")
    

Final note

Always make sure input() receives exactly one string (or no arguments at all, if you don't need a prompt). That's all it takes to fix this error!

内容的提问来源于stack exchange,提问作者MossyAB

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.27 03:48:11