I have my txt file something like this.
[0, "we break dance not hearts by Short Stack is my ringtone.... i LOVE that !!!.....\n"]
[1, "I want to write a . I think I will.\n"]
[2, "@va_stress broke my twitter..\n"]
[3, "\" "Y must people insist on talking about stupid politics on the comments of a bubblegum pop . Sorry\n"]
[4, "aww great "Picture to burn"\n"]
I have a some code which want to access the 2nd element of each array. When I use the code from Get the nth element from the inner list of a list of lists in Python It is giving each characters but not the entire string.
What could be the best way to make a loop for getting second element?
My code is something like this.
ALl the tweets are in the tweets[] list.
cluster = []
for idx, cls in enumerate(km.labels_):
if cls == 1:
# printing cluster 2 data.
# print tweets from the tweets array. like the entire line. But I
# want to get the String here not the entire line.
print tweets[idx]
cluster.append(tweets[idx])
Here, idx element is used to get specific queries. so tweets[idx] will print specific queries from the text file but It is printing the entire line like [2, "@va_stress broke my twitter..\n"] and I want string element only.