I have a python tuple whose elements are actually sentences. I want to compare the first letters of each element, and if they are lowercase, I join the previous element. And if they are not me, I just join the first element. For example, if I have:
tuple1 = ('Traditionally, companies have been communicating', 'with consumers through traditional or old media.', 'The rapid changes in the cyber world.', 'This is another sentence', 'which is incomplete.')
My result should be:
tuple1 = ('Traditionally, companies have been communicating with consumers through traditional or old media.', 'The rapid changes in the cyber world.', 'This is another sentence which is incomplete.')
This is my working code:
i=0
while i<(len(tuple1)-1):
if tuple1[i+1][0].islower():
tuple1[i] + " " + tuple[i+1]
i+=1
How can i achieve this? Thanks
source
share