0

Can someone tell me why my code is working for only one input. if try to run it second time by typing yes then it prints none

https://code.sololearn.com/ceUd6sR9SFVD/?ref=app

30th Aug 2020, 7:26 PM
Krishna Agrawal
Krishna Agrawal - avatar
6 Réponses
+ 1
#Return the function list={} def mine(): a1=input('enter your variable:-') print() a2=input('enter its value:-') print () list[a1]=a2 a3=(input('Do you want to enter any new variable:-')).lower() print() if a3=='yes': return mine() # added return elif a3=='no': a4=list return a4 print(mine()) https://code.sololearn.com/cwe7v5vjVw3n/?ref=app
30th Aug 2020, 8:23 PM
Steven M
Steven M - avatar
+ 1
You should enter all input at once Like this👇 X 4 yes Y 5 no
30th Aug 2020, 7:31 PM
Ajith
Ajith - avatar
+ 1
Thanks Steven and jayakrishna. You both are correct but I like Steven's answer
30th Aug 2020, 9:27 PM
Krishna Agrawal
Krishna Agrawal - avatar
+ 1
Krishna Agrawal, If possible, try not to use type name as variable name. `list` is a type name, and thus it would be inappropriate being used as variable name, may cause confusion or unexpected behaviour 👍
30th Aug 2020, 9:43 PM
Ipang
0
list={} def mine(): a1=input('enter your variable:-') print() a2=input('enter its value:-') print () list[a1]=a2 a3=(input('Do you want to enter any new variable:-')).lower() print() if a3=='yes': mine() return list #No need else, return from else goes last call of mine() and first call to mine() then retuning nothing.. print(mine())
30th Aug 2020, 8:38 PM
Jayakrishna 🇮🇳
0
Thanks bro for your suggestion. But I know it. And it is just a sample part of a big program and I tried to make it as simple as possible
31st Aug 2020, 5:09 PM
Krishna Agrawal
Krishna Agrawal - avatar