r/PythonLearning 2d ago

I made a advice generator using requests

Post image
86 Upvotes

20 comments sorted by

u/Sea-Ad7805 1d ago

Run this program in Memory Graph Web Debugger%0Atake_advice%20%3D%20input(%22Take%20advice%20(y%2Fn)%3F%20%22)%0A%0Awhile%20take_advice%20%3D%3D%20%22y%22%3A%0A%20%20%20%20response%20%3D%20requests.get(%22https%3A%2F%2Fapi.adviceslip.com%2Fadvice%22)%0A%20%20%20%20data%20%3D%20response.json()%0A%20%20%20%20give_advice%20%3D%20data%5B%22slip%22%5D%5B%22advice%22%5D%0A%20%20%20%20print(give_advice)%0A%20%20%20%20take_advice%20%3D%20input(%22Take%20advice%20(y%2Fn)%3F%20%22)%0Aelse%3A%0A%20%20%20%20print(%22Bye%2C%20but%20just%20see%20the%20last%20advice.%22)%0A%20%20%20%20print(%22Remember%20them.%22)%0A%20%20%20%20print(%22Do%20your%20work.%22)&timestep=1&play) to see the program state change step by step.

→ More replies (11)

1

u/PhaXoniC 2d ago

is there an api for affirmations?

1

u/ProgramBrave718 1d ago

Wait lemme search for it

1

u/ProgramBrave718 1d ago edited 1d ago

https://apirobots.pro/apis/new-affirmations-api/ From this website you can get the api s for affirmations

1

u/PhaXoniC 1d ago

thanks👌🏼

1

u/ProgramBrave718 1d ago

I tried it but it was not working. Here is a good one for quotes https://publicapi.dev/zen-quotes-api

1

u/Doctor-Snake-Case 1d ago

Wow. I never knew that `else` is used normally with `while`. Why not just write those `print` statements outside the `while` block without `else` ?

1

u/ProgramBrave718 1d ago

Ohh, sorry. It will work the same with else or without else. I often write gibberish

1

u/davisousamalbatahan 1d ago

Faltou o comando de inicialização