Hello,
This is my first post here..
Using Python 2.7, and I am relatively new to python.
I am trying to find a way to make a function for replacing the same value in several string-variables. As of now I am replacing the value by each string (see below).
The variables p1, p2 and p3 are strings with the current syntax: xxx.xx - example: p1 = 990.21, and I want to find out if they are numeric or not.
I have tried doing the following, but I get an tuple-error: attributeerror 'tuple' object has no attribute 'replace'
The internet has given me no answers so far - could be that I do not know what exactly to search for..
This is my first post here..
Using Python 2.7, and I am relatively new to python.
I am trying to find a way to make a function for replacing the same value in several string-variables. As of now I am replacing the value by each string (see below).
The variables p1, p2 and p3 are strings with the current syntax: xxx.xx - example: p1 = 990.21, and I want to find out if they are numeric or not.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
if p1.replace( '.' ,'').isdigit(): pass else : print 'P1 NOT ok' if p2.replace( '.' ,'').isdigit(): pass else : print 'P2 NOT ok' if p3.replace( '.' ,'').isdigit(): pass else : print 'P3 NOT ok' |
1 2 3 4 |
if (p1, p2, p3).replace( '.' ,'').isdigit(): pass else : print 'P NOT ok' |