boB Stepp <[email protected]>:
> According to the OP's professor's challenge, the OP needs to recognize
> an input of "4.0" as a float and "4" as an integer, and to respond
> with an error message in the float case, or "decimal number" case as
> the OP phrased it. Apparently only positive integers are acceptable
> input; all other inputs should generate an appropriate error message
> by input type.
Haven't been following the discussion, but this should be simply:
ast.literal_eval("...")
For example:
>>> ast.literal_eval("( 1.0, 3 )").__class__.__name__
'tuple'
Marko
--
https://mail.python.org/mailman/listinfo/python-list