+ 1
How could I fix this could to check if they're any numbers within the input and not give an error?
https://code.sololearn.com/cJhxG9LzEuhq/?ref=app I have tried to fix it many times but need help. It's supposed to check the password and see if it's missing numbers or the length is too short.
4 odpowiedzi
+ 3
if nums not in x: this checks list in string. Wrong. You need to check string is in list. But list having numbers in int format but you are checking str format numbers. You need compatible types, otherwise always returns false.
Try
if x in "0123456789" : or if int(x) in nums :
Next len(15) is invalid in
if passwrd < len(15):
Try
if len( password) < 15 :
And again. You need to check this only once so write it before loop. Not inside.
Also for least one number, you are print for each character. Not for entire string.
Try again to correct it..
hope it helps..
+ 3
It's not the only problem. Jayakrishna 🇮🇳 is right. However, there is another problem to why it is not running in Sololearn Playground.
It seems like you copied code from somewhere, and therefore some "invisible" characters that can't be understood by an interpreter got copied too. Which caused an error. There is the fixed code (without second point mentor have made )
https://code.sololearn.com/ck2vsZ7qih65/?ref=app
+ 2
Thank you for the help
+ 1
1. The code checks password length once for each character, what doesn't make sense (the length is the same in all iterations). Check only once.
2. When length is ok (>=5), the code skips the rest of the code block inside the loop (continue). So it never checks the characters. Rethink the loop logic.
3. The code should tell whether there's numbers in the password but, instead, it's telling whether each character is a number. Store the result and only print it at the end.