0

I'm looking to loop print synonyms for each item from my list

myList = ["First", "Second", "Third"]

tried few loop methods with no success, please help

to print them manually 1 by 1 the command is

response = unirest.get("https://wordsapiv1.p.mashape.com/words/first/synonyms", headers={ "X-Mashape-Key": "**MY -Mashape-Key", "Accept": "application/json" } )

response.body <===this will print synonyms for word "first"

How do i loop to print the body for all the words in my list ? Thanks

alizahid
  • 959
  • 6
  • 17
totheM
  • 3
  • 2

1 Answers1

0

Try this

for word in myList
    response = unirest.get("https://wordsapiv1.p.mashape.com/words/" + word + "/synonyms", headers={ "X-Mashape-Key": "API_KEY", "Accept": "application/json" } )
    print response.body

I don't know Python, but from its documentation, it seems it should work.

alizahid
  • 959
  • 6
  • 17