I need to implement python built-in type convert function:
The code should convert the following 3 strings into real values:
What python functions are not allowed:
1. the type convert function itself: int(), float()
In other words....
Define a function, that takes a string format number as input, and return the number itself.
e.g. def stringToNumber(str):
#your code here
How to write a python script, that converts a string format number into 'real' number: integer, float.
Post a Reply
Replies- page 2
|Oldest Newest Rating|
Bernard Pyc0d333 Parah
· September 19, 2015
Agree with Clark
.isdigit() definitely does the trick
you can also use a third-party module like fastnumbers if you wish
you might have to download the module.
and then you could also always use the yaml method of doing that
· September 18, 2015
I dont believe it's possible to convert string to integer without some kind of build-it functions.
You can get for example first or whichever number in string format with:
Or you can get id number of character ( character = string with 1 letter)
This section is all about snakes! Just kidding.
|Bucky Roberts Administrator|