Aug 8, 2007 #1 ddrillich Technical User Joined Jun 11, 2003 Messages 546 Location US Good Day, How do I find out if a certain string represents a number? Regards, Dan
Aug 8, 2007 1 #2 feherke Programmer Joined Aug 5, 2002 Messages 9,541 Location RO Hi [tt]isdigit()[/tt] ? Code: [blue]>>>[/blue] 'abc'.isdigit() False [blue]>>>[/blue] '567'.isdigit() True [blue]>>>[/blue] '567x'.isdigit() False Feherke. http://rootshell.be/~feherke/ Upvote 0 Downvote
Hi [tt]isdigit()[/tt] ? Code: [blue]>>>[/blue] 'abc'.isdigit() False [blue]>>>[/blue] '567'.isdigit() True [blue]>>>[/blue] '567x'.isdigit() False Feherke. http://rootshell.be/~feherke/
Aug 8, 2007 Thread starter #3 ddrillich Technical User Joined Jun 11, 2003 Messages 546 Location US Great! In the code, should I say - if (theString.isdigit() == "True"): I'm not sure about the syntax... Upvote 0 Downvote
Great! In the code, should I say - if (theString.isdigit() == "True"): I'm not sure about the syntax...
Aug 8, 2007 Thread starter #4 ddrillich Technical User Joined Jun 11, 2003 Messages 546 Location US if (SPNcandidate.isdigit() == 1): worked Upvote 0 Downvote
Aug 8, 2007 #5 feherke Programmer Joined Aug 5, 2002 Messages 9,541 Location RO Hi No, should be without the quotes ( " ) : Code: if (theString.isdigit() == True): But while [tt]isdigit()[/tt] returns boolean, why to compare it with another boolean to get a boolean ? Code: if (theString.isdigit()): Feherke. http://rootshell.be/~feherke/ Upvote 0 Downvote
Hi No, should be without the quotes ( " ) : Code: if (theString.isdigit() == True): But while [tt]isdigit()[/tt] returns boolean, why to compare it with another boolean to get a boolean ? Code: if (theString.isdigit()): Feherke. http://rootshell.be/~feherke/