# RWET – Loops and Lists

This week in Reading and Writing Electronic Text I worked with loops and lists to make a script that breaks a series of headlines up into a sort of 24 hour clock. The idea is that each headline its slowly revealed over the course of a day as a play on the idea of the 24 hour news cycle.

I started with a text file that contained headlines from a bunch of large news outlets:

PROBLEM OF THEIR OWN Canada sees spike in border crossings from US
Rex Tillerson Arrives in Mexico Facing Twin Threats to Relations
Kim Jong-nam killing: North Korea condemns Malaysia
ACLU Sues Milwaukee Over Police Stop-and-Frisk Policy
Trump Meets With Corporate CEOs Thursday on Economic Policies
Bannon told EU it was flawed just before Pence’s visit
7 potentially habitable exoplanets discovered
2 cops charged in Florida woman’s accidental shooting death
Obama-linked activists have a ‘training manual’ for protesting Trump

I then shuffled the order of the headlines (to keep the output interesting) and broke each line into a list of words. The number of words in each line was used to figure out how to display it over the course of a day and then each word is designated a time slot. I created a loop to simulate a 24 hour cycle with this method. I imagine this could be a part of an installation that would act live a very slow moving new ticker.

The code:

import sys
import random
all_lines = []
minutes = -60
lines = []

for l in sys.stdin:
lines.append(l.strip())

random.shuffle(lines)

for line in lines:
line = line.strip()
word = line.split(” “)
all_lines.append(word)

for x in range(24):
currentWordNum=[]
minutes+=60
print “\n”,
print str(minutes/60)+(“:00”)
for i in range(len(all_lines)):
print all_lines[i][currentWordNum[i]]

The output:

Trump

7

ACLU

Rex

PROBLEM

Bannon

Kim

2

Trump

7

ACLU

Rex

PROBLEM

Bannon

Kim

2

Trump

7

ACLU

Rex

OF

Bannon

Kim

2

Meets

activists

7

ACLU

Tillerson

OF

told

Kim

cops

Meets

activists

7

Sues

Tillerson

THEIR

told

Jong-nam

cops

Meets

activists

potentially

Sues

Arrives

THEIR

EU

Jong-nam

cops

With

have

potentially

Sues

Arrives

OWN

EU

Jong-nam

charged

With

have

potentially

Milwaukee

Arrives

OWN

EU

killing:

charged

Corporate

a

potentially

Milwaukee

in

it

killing:

in

Corporate

a

potentially

Milwaukee

in

it

killing:

in

Corporate

a

habitable

Milwaukee

Mexico

sees

was

killing:

in

CEOs

‘training

habitable

Over

Mexico

sees

was

North

Florida

CEOs

‘training

habitable

Over

Facing

spike

flawed

North

Florida

CEOs

‘training

habitable

Over

Facing

spike

flawed

North

Florida

Thursday

manual’

habitable

Police

Facing

in

flawed

Korea

woman’s

Thursday

manual’

exoplanets

Police

Twin

in

just

Korea

woman’s

on

for

exoplanets

Police

Twin

border

just

Korea

accidental

on

for

exoplanets

Police

Threats

border

before

Korea

accidental

on

for

exoplanets

Stop-and-Frisk

Threats

crossings

before

condemns

accidental

Economic

protesting

exoplanets

Stop-and-Frisk

Threats

crossings

before

condemns

shooting

Economic

protesting

discovered

Stop-and-Frisk

to

from

Pence’s

condemns

shooting

Economic

protesting

discovered

Policy

to

from

Pence’s

Malaysia

shooting

Policies

Trump

discovered

Policy

Relations

US

visit

Malaysia

death

Policies

Trump

discovered

Policy

Relations

US

visit

Malaysia

death