RWET – Functions

This week I took my previous assignment and tried to get all the printing to work through a function. I got it all working in the end but I had a surprising amount of difficulty.

I call the function like this:


Here’s an example of the result, which hasn’t changed much.


Ashwin’s dig: March 30 will be known as ‘World Apology Day’ – Times of India


Both Houses adjourned till 11 am on March 31

Does Science Advance One Funeral at a Time?


Both Houses adjourned till 11 am on March 31


Supreme Court refers triple talaq case to 5-judge constitutional bench; hearing to begin May 11 – Times of India

No stamping of flyers’ handbags at 7 airports from April 1 – Times of India

I tried to set this aside as a module but It required a lot of libraries and variables from my main script. I guess I could have passed all those through as parameters but it felt kinda hacky so I left it all as one file.

RWET – Poetic Form

I  once again continued working with news headlines this week. However this time I think I have a more robust collection of headlines. I found a news api that lets me pull in over 550+ headlines from 60 different news sources. The code I wrote basically gets the list of sources from the API and then uses that list to request 10 headlines from each source. These headlines are then saved in a list together and then if any of them contain numbers (in either written or numerical form) they are sorted into another list based on the numbers they use. E.g “Five people discover volcano”   would be assigned to a list within the 5th slot of another list. I then got the real time and date and tried to have the program print the date and time using these headlines. Here are some results:

Read More


I continued to work with headlines and news. This time I used an API to grab the most popular headlines on and pick a random word to replace with a definition from Oxford dictionary. Sometimes the results don’t make sense but every now an then an interesting replacement occurs. Here are some examples of the output (my favorites are in bold):

Read More

RWET – Cut up 2: Sets and dictionaries

This week I continued to work with news and tried to make some lightly cut up headlines. What I ended up with is a script that reads in a whole article, splits it into headlines and body (kind of hacky), finds words unique to each article and then randomly replaces words in the headlines with these unique words. Here are some results:

I had to run this a bunch of times to get good results but I was happy with the way it created this news blending effect. I could see working more on distorting news articles.

The code is a bit sloppy this time but I was able to to make some light usage of dictionaries and sets. I found myself relying on lists a lot out of familiarity but could begin to see how other structures would be useful.