Search code examples
pythonpython-3.xpygame

PYTHON 3 I need help. I have already checked similar problems.TypeError: input expected at most 1 argument, got 2


Here is my Error.

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "main.py", line 21, in welcome
    name2 = input("\nPardon? Did you say",name+"?")
TypeError: input expected at most 1 argument, got 2

Here is my code.

import random
import time

def welcome():
  #Tutorial
  print("============================================")
  print("Welcome to Blunderberg RPG by ChillingPixel")
  print("The goal is just to have fun and stay alive.")
  print("Yes, No, North, South East, West, are all ")
  print("valid inputs.")
  print("                 Have fun!")
  print("============================================")
# Meeting Old Man Thorley
  time.sleep(5)
  name = input("\nBed and Breakfast Owner:\nWelcome Young traveler what is your name? ")

  time.sleep(2)
  print("Nice to meet you",name,". My name is Old Man Tho—. Wait! Did you say your name was",name,"?")
  
  time.sleep(3)
  name2 = input("\nPardon? Did you say",name+"?")
  if name2 in("Yes,yes,yea,Yea,Yeah,yea,y,Y"):
    game()


def game():
  time.sleep(3)
  print("Testing 123")

I want to be able for the user to confirm that that is what he said, and if he says yes then it take him to the game(). Sorry im new to Python


Solution

  • Replace comma with + sign

    name2 = input("\nPardon? Did you say"+name+"?")
    
    # or use f-string, same result
    name2 = input(f"\nPardon? Did you say {name} ?")
    
    

    You need to concatenation the string. By using comma, you are passing two arguments. But input() takes only one argument