Nov-07-2016, 06:39 PM
(Nov-03-2016, 07:50 PM)roadrage Wrote: All of the elements in list b are coming up as type str, how to convert them to int or float??
As easily as asking nicely that they be int or float:
>>> x = '534' >>> type(x) <class 'str'> >>> y = int(x) >>> type(y) <class 'int'> >>> z = float(x) >>> type(z) <class 'float'>That said, why are you using ast for anything this simple? You're not creating blocks of code and traversing the call stack, you're just... multiplying numbers...
Speaking of which, why define a multiply function if you'll never call it?