On Tue, 20 Dec 2005 15:55:37 +0100, egbert wrote:
> On Tue, Dec 20, 2005 at 07:16:46PM +0530, Suresh Jeevanandam wrote:
>> s1 = '12e3'
>> s2 = 'junk'
>> Is there any other function which would return True for s1 and False
>> for s2.
>>
>
> isinstance(12e3, (int, float))
That won
On Tue, 20 Dec 2005 19:16:46 +0530, Suresh Jeevanandam wrote:
> Hi,
> I have a string like,
> s1 = '12e3'
> s2 = 'junk'
>
> Now before converting these values to float, I want to check if they
> are valid numbers.
Just try converting them:
float_list = []
for s in strin
On Tue, Dec 20, 2005 at 07:16:46PM +0530, Suresh Jeevanandam wrote:
> s1 = '12e3'
> s2 = 'junk'
> Is there any other function which would return True for s1 and False
> for s2.
>
isinstance(12e3, (int, float))
--
Egbert Bouwman - Keizersgracht 197 II - 1016 DS Amsterdam - 020
You should probably work through the tutorials.
Use a try block:
try: x=float(s)
except ValueError:
print 'Non-numeric value %s found' % s
-Larry Bates
Suresh Jeevanandam wrote:
> Hi,
> I have a string like,
> s1 = '12e3'
> s2 = 'junk'
>
> Now before converting these values
On 20/12/05, Suresh Jeevanandam <[EMAIL PROTECTED]> wrote:
Hi,I have a string like,s1 = '12e3's2 = 'junk'Now before converting these values to float, I want to check if theyare valid numbers.s1.isdigit returns False.
Is there any other function which