0
[Solved] How to get input into a list via a function?
How can I get input from inp_cus_1 (lines 527 and 531) into the lis_cus list (line 86) using the app_cus() function (defined on line 122)? https://code.sololearn.com/cmfyA55BOLhm/?ref=app
6 Answers
+ 2
I think you are trying this :
def app_cus(age):
lis_cus.append(age)
inp_cus_1 = input()
if inp_cus_1:
app_cus(inp_cus_1)
+ 1
def app_cus(age):
lis_cus.append(age)
for i in range(3) :
inp_cus_1 = input()
if inp_cus_1:
app_cus(inp_cus_1)
#like this Adam Stork .but Iam not sure, you are looking like this or not.
Above what I said is like this but it takes more lines :
def app_cus(age1,age2,age3):
lis_cus.append(age1)
lis_cus.append(age2)
lis_cus.append(age3)
inp_cus_1 = input()
inp_cus_2 = input()
inp_cus_3 = input()
app_cus(inp_cus_1, inp_cus_2,inp_cus_3)
#add conditions, if you need to Check input is not empty or not like you did previously..
0
Jayakrishna🇮🇳 Thank you!
Though I forgot to mention that there will also be inp_cus_2 and inp_cus_3. Is it possible to handle all three inputs via one function?
0
Yes.
Take 3 inputs. And pass 3 inputs as well collect 3 inputs in function defination..
0
Jayakrishna🇮🇳 I'm not sure how you mean, could you show me on a code, please?
0
Jayakrishna🇮🇳 I will try, thank you!