Problem C
Extracting a Number
Write a function extract_first_number_from_string(string_to_search)
which takes a string as a parameter. The function should
extract the first number from the string and return it as an
integer, or return
Note that we are testing your code differently in this task, please only submit your function definitions, without any code outside the functions! The main python file, which handles input and output, is already provided. You can download and place the main file in the same directory as your python file. You can then run the main python file we provide to try out the samples.
Input
The input consists of one string which is at least
Output
The output of the function should be one integer, the first
number contained in the input string, or
Sample Input 1 | Sample Output 1 |
---|---|
There are 365 or 366 days in the year. |
365 |
Sample Input 2 | Sample Output 2 |
---|---|
These are not the numbers you are looking for. |
-1 |
Sample Input 3 | Sample Output 3 |
---|---|
-1 |
Sample Input 4 | Sample Output 4 |
---|---|
Assignment7 is gr8 and all but do check out the extra assignment 2 |
7 |