How to make a function and input it's arguments | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

How to make a function and input it's arguments

I wanna make a function like this def func (×): return Func (input ()) But when I try I get an error

27th Dec 2019, 12:34 PM
Pattern
Pattern - avatar
4 Answers
+ 5
You need to convert the inputs for both functions to int before you can use them for calculation. (input always returns string format whatever you input) There is also a colon ":" missing at the end of header from second function. def add(x,y): return x+y print(add(int(input()),int(input()))) #input needs to be converted to int # and i also was tring this def divide(x,y): assert int(y)>0 return x/y print(divide(int(input()),int(input()))) #input needs to be converted to int
27th Dec 2019, 1:22 PM
Lothar
Lothar - avatar
+ 2
Can you show us the program?
27th Dec 2019, 1:01 PM
HonFu
HonFu - avatar
27th Dec 2019, 1:14 PM
nelida murataj
nelida murataj - avatar
0
https://code.sololearn.com/cZC99PcUcA5G/?ref=app
27th Dec 2019, 1:09 PM
Pattern
Pattern - avatar