read several lines in python 3

0

Nesesito read several lines in python 3, I have this without pressing ENTER: Love Rome Hello Hello Occasionally Staging bear dog Possessionary Possession Colombia Locombia Mommy Mommy and I need python to read me all the lines and print me in a list [[Love, Rome] [Hello, Hello] ......]

Any way to solve this? Thanks!

    
asked by DDR 20.01.2018 в 20:27
source

1 answer

1
palabras = "primera segunda tercera cuarta"

lista_palabras = palabras.split(" ")
lista_pares_palabras = []
for i in range(0, len(lista_palabras),2):
    lista_pares_palabras.append([lista_palabras[i],lista_palabras[i+1]])


print(lista_pares_palabras)

output:

  

[['first', 'second'], ['third', 'fourth']]

    
answered by 21.01.2018 / 00:42
source