+ 1
Isnumeric() function don't works correctly.
I am working on a affine cipher, and I want to add the possibility to use negative numbers. I have in my program a condition for verify if the keys entered by the user are integers using the isnumeric() function. But, as you can see on my program, I had to remove the "-" sign using the replace() function to verify if the string is a number. But, when this test occur It tells me that it's not a number... What have I done wrong ? P. S. : I know that after correct this problem I have to make a backup for the initial keys to recover them after replace the string. https://code.sololearn.com/c4n2rDZPx8yX/?ref=app
6 Réponses
+ 3
def isValid(message):
allowed="0123456789-"
if all([i in allowed for i in message]):
return True
return False
+ 1
in stead of answering, could i ask a question?😳😳😳😳
+ 1
Thanks you :D
0
Of course you can !
But bro if it's because my english is bad or I look like a script kiddie I apologize x)
0
What does the following code do ?
if replacedA.isnumeric() == False or replacedB.isnumeric() == False
0
It supposed to stop the program if replacedA or replacedB are not numbers