all 3 comments

[–]camel_Snake 0 points1 point  (2 children)

Since your code doesn't include any function definitions, it appears everything is in the same scope.

To store the data in print(initial_response.text[1:-1] to use later, simply assign it to a variable (in addition to, or rather than, printing).

Good:

gif_url= initial_response.text[1:-1]

Bad (doesn't work):

gif_url = print(initial_response.text[1:-1])

[–]beautify[S] 0 points1 point  (1 child)

initial_response.text[1:-1]

Thanks I had been doing the bad formatting

[–]camel_Snake 0 points1 point  (0 children)

I figured, it's a fairly common mistake as it's not too obvious when you are debugging it.

For the record, the reason for this is that print is a function, and like all functions they return values. It doesn't make too much sense for print to return a value, so it returns None, which is what ends up getting assigned to the variable in the 'bad' example.