0
num_trades = int(input("Number of trades for today? "))
for i in range(1, num_trades + 1):
    print()
    action = input("Trade number", i, "(buy/sell)? ")
    num_shares = int(input("Number of shares to buy? "))

I'm getting a TypeError on the line,"action = input("Trade number", i, "(buy/sell)? ")"

This error message says "TypeError: input expected at most 1 arguments, got 3"

Don't know what it means and don't know how to correct. Help

Thanks

Grijesh Chauhan
  • 57,103
  • 20
  • 141
  • 208
user88453
  • 1
  • 4

4 Answers4

5

You are passing 3 arguments to input():

action = input("Trade number", i, "(buy/sell)? ")

and it only takes one; only print() takes multiple arguments. Use string formatting:

action = input("Trade number {} (buy/sell)? ".format(i))

or use string concatenation:

action = input("Trade number " + str(i) + " (buy/sell)? ")

but that requires you to turn i into a string explicitly.

Martijn Pieters
  • 1,048,767
  • 296
  • 4,058
  • 3,343
1

That's because you're calling input with 3 arguments

use

input("Trade number " + str(i) + " (buy/sell?")

instead

Grijesh Chauhan
  • 57,103
  • 20
  • 141
  • 208
sharcashmo
  • 795
  • 1
  • 7
  • 16
0

The error is telling you exactly what is wrong. The input function expects one argument, but you gave it three.

Instead of

input("Trade number", i, "(buy/sell)? ")

Try

input("Trade number " + str(i) + " (buy/sell)? ")

You're probably confused, because you can print multiple things, by separating them with commas, but 99% of the places, that won't work. input expects you to give it one string argument, and by placing commas there, you've given it three arguments. My suggestion concatenated those three strings into one, which we passed to input.

Jonathon Reinhart
  • 132,704
  • 33
  • 254
  • 328
0

the function is taking just one argument, not 3. Did you mean:

num_trades = int(input("Number of trades for today? "))
for i in range(1, num_trades + 1):
print()
action = input("Trade number " + str(i) + " (buy/sell)? ")
num_shares = int(input("Number of shares to buy? "))