Why is there a RecursionError? | Sololearn: Learn to code for FREE!
0

Why is there a RecursionError?

Im doing a password and login program, Im trying to solve a problem. https://github.com/cloroxide/Problems/blob/master/password.py When I Input "yea" at the Do You Want to Sign in Part It shots Please Type Yes Or No Until a RecursionError How to fix without messing up code?

30th Jun 2020, 2:10 PM
slawbear
slawbear - avatar
6 odpowiedzi
+ 6
Here is your code reworked so that it works. As mentioned from others, the code can be optimized in several ways. But this is an other item. https://code.sololearn.com/c5HVgFjpfYDV/?ref=app
30th Jun 2020, 3:24 PM
Lothar
Lothar - avatar
+ 4
The way your code is done currently, it produces an infinite loop, which calls a recursion in each loop. So the recursion level will be reached and the program crashes. In the task you are doing in this code, recursion is not needed. Try to make a loop around your code. Anyway, i will show you how you can get rid of the problem with the infinite loop. take the input from second line, and put it into top of the function: prijnt("Do you want to sign up?") #sign = str(input()) def q1(): sign = input('Do you want to sign in?') # no need to convert input to string! if sign.lower()=="no": print("Okay, have a nice day!") exit() ... There is also an issue with split() function. You don't need to give an argument to that function, as aplit() removes all leading and trailing whitespaces.
30th Jun 2020, 2:25 PM
Lothar
Lothar - avatar
0
Can you give me an example of a code that will fix it? @Lothar
30th Jun 2020, 2:32 PM
slawbear
slawbear - avatar
0
@Bagon I dont understand the while sign not in ["no", "yes"]: why did you put that? and why did you put global on the sign function, it already is an global function? btw nice code correction thanks!
30th Jun 2020, 2:44 PM
slawbear
slawbear - avatar
0
@Bagon Hey I tried to put a blank username and it says You can't put a blank username like intended but after that it just shows a blank space and if i press enter, another blank space. entering a character won't solve it how?
30th Jun 2020, 2:57 PM
slawbear
slawbear - avatar
0
@Bagon I want it to continue asking for a username and password
30th Jun 2020, 3:11 PM
slawbear
slawbear - avatar