-1

E.g "input("what is",a,b,c,"?")"

However this doesn't work

a is a random number

b is a + sign

c is another random number

When i try and run the code it says: :TypeError: input expected at most 1 arguments, got 5

p.s im am new to coding so please use simple language so that i can understand

3 Answers3

1

I think your issue is a fundamental misunderstanding of how input works. It's really difficult to parse out what you're trying to do with the input, but I'll give it a shot.

The 'input' function asks the user for exactly that, input. It will then store that input somehow. Usually you'll want to assign it to a variable, as in:

inputString = input('What is a, b, c')

From there, you could apply formatting to inputString, and then assign that to variables as well. Reading the official documentation, as well as doing a cursory search for the '.split()' method will likely give you what you're looking for.

This existing SO question may also yield some helpful information for you

In my experience, Google is your absolute best friend, especially when starting out. I'm not here to flame you and put you down, but the majority of SO users will expect you to exhaust all your personal resources and do at least the minimum amount of basic research before posting here. All I looked for to get to the linked post was "getting multiple variables from user input python" in Google. Taking care of this beforehand will save you a lot of negative votes, and generally yield more helpful, positive experiences here.

Edit: It should be noted that a lot of what I covered in the last paragraph is clearly outlined in the rules of the site. Not following them will have negative repercussions outside of the dislike of your peers.

Community
  • 1
  • 1
Inagnikai
  • 281
  • 1
  • 15
0

You need to provide a single string argument when calling input, i.e. input("enter input now"). If b is always a +, try input("what is {}+{}".format(a,c)). The first argument in format will replace the first {} in the string, the second argument in format will replace the second {} in the string, and so on.

Greg
  • 597
  • 1
  • 6
  • 16
0
import numpy as np
a= np.random.randint(0,10)    
b = "+"
c = np.random.randint(0,10)

print("what is 'a,b,c'", eval(str(a)+str(b)+str(c)))

If you want to input a random number and assign it to a and b. You should use following:

a = input("Value of a?\n")
b = input("Value of b?\n")
MaThMaX
  • 1,995
  • 1
  • 12
  • 23