Parsing results back through to the input of a function

image

My Code:

Excuse me if I have missed this from a lesson (I checked and I don’t see this being mentioned anywhere), but in the above image the function’s input allows the results from the body of code to be returned to the input/parsing variable (string_b) and be stored within it - returning & storing a list of the formatted data even though you’ve already parsed your data into string_b

My problem is that I can’t find this being mentioned elsewhere as a topic or even talking point - it’d be useful to have a bit more of an explanation of how this works…!

HI @burhaan.quinn: I think you misunderstood the concept of the return statement of a function. The return statement returns value(s) as stored in variables, lists or strings datatypes etc. to the main program. In this case string_b is modified to become an int type from the string type. You can choose to call the function and save the return value in the main program.

Next time, please include a link to the mission as per these guidelines.

#let's say string_b is 01-10-2020
def process_date(string_b):
    ...
    return string_b 


result = process_date(string_b) #string_b becomes 01102002

You can choose to store the return value in a variable like result if you require the use of this in the main program.

Hope this clarifies.

1 Like

Thanks for clarifying, @masterryan.prof .

In essence my thinkings are just misinterpretations of the use of the function in this case.

Best,
BQ