def add_num(num1,num2):
num3 = num1+num2
return(num3)
func = add_nums(input("type any number\n"),num1 = input("type any number\n"))
print(func)
Asked
Active
Viewed 35 times
-5

Marco Bonelli
- 63,369
- 21
- 118
- 128
-
1There are no numbers in this code at all - the result of `input()` is a string, you'd need to use `int()` or `float()` on those strings to turn them into numbers. – jasonharper Aug 27 '22 at 00:10
-
1I think you can find at least a thousand of websites that answer your question. I'd suggest you to follow a tutorial on python programming fundamentals. – mikyll98 Aug 27 '22 at 00:11
-
Welcome to Stack Overflow. For future questions, please read [ask]. "how do I fix the code" can only be answered if a *specific problem* is identified. Please use the post itself to ask the question, using full English sentences to explain: what happens when you try the code? What is supposed to happen instead, and how is that different? Then ask a question in the post itself, starting with a question word like "why" or "how" and ending with a question mark (`?`). Use the post title to summarize, not to do all the asking. – Karl Knechtel Aug 27 '22 at 00:29
1 Answers
0
You have to make the input be saved as a number, by applying a float on the input function you will make the add_nums
function first parameter a number then the function will receive it as a number and will be able to do that also for the second parameter for the function to be able to add the numbers as you described.
This function will work just fine.
def add_nums(num1, num2):
return num1 + num2
func = add_nums(float(input(f"Please type a number\n")), float(input(f"Please enter a second number: ")))
print(func)

Roy
- 398
- 2
- 12