How can I make the below code to accept input from users??? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

How can I make the below code to accept input from users???

def average(n1,n2,n3): total= int(n1) + int(n2) + int(n3) Avg = total/3 return Avg print(average(5,2,3))

22nd Jun 2021, 11:06 PM
Al-hassan Rabi'u
Al-hassan Rabi'u - avatar
2 Answers
+ 3
print(average(input(), input(), input()))
22nd Jun 2021, 11:52 PM
你知道規則,我也是
你知道規則,我也是 - avatar
+ 1
Hi Al-hassan Rabi'u There is a input() function in python for taking user input, input accepts str input if you want to take a input as a int, then you have to convert your str in int, using int() function! Conclusion : int(input())
23rd Jun 2021, 1:50 AM
Abhiyantā
Abhiyantā - avatar